Compare commits

...
938 Commits
Author SHA1 Message Date
Wilson Snyder 484b76e5b3 Version bump 2021-01-10 13:34:59 -05:00
Wilson Snyder 801d850724 Commentary 2021-01-10 13:14:25 -05:00
Paul Wright 769c0fa318 Fix to ignore coverage on real ports (#2741) (#2745) 2021-01-10 12:40:03 -05:00
Julien Margetts a11700271f Add LATCH and NOLATCH warnings (#1609) (#2740). 2021-01-05 14:26:01 -05:00
Wilson Snyder 6d80e8f856 Test update 2021-01-05 09:04:31 -05:00
Wilson Snyder f57c72e5db clang-format 2021-01-03 12:01:14 -05:00
Wilson Snyder 7eeb930c72 examples: Use unique_ptr 2021-01-03 11:54:43 -05:00
Yutetsu TAKATSUKASA 5b280c1911 Fix hierarchical verilation with explicit setting of default parameter value (#2738)
* Test hierarchical block that is explicitly set its default parameter value.

* Fix hierarchical verilation when a hierarchical block is instantiated with explicit setting of the default value.

Parameterized hierarchical block must have mangled name even when all parameters have default value,
otherwise the parameterized module will be hidden by protect-lib wrapper.

* rename variable names. No functional change is intended.
2021-01-03 12:19:37 +09:00
Wilson Snyder 1a073fbf5e Fix vpiLeftRange on little-endian memories (#2696). 2021-01-02 22:00:13 -05:00
Wilson Snyder 83d978c2cd Fix generate for unrolling to be signed (#2730). 2021-01-02 21:43:13 -05:00
Wilson Snyder a17e2375b3 CI: Need flexlexer for internal coverage testrun 2021-01-02 21:42:41 -05:00
Yutetsu TAKATSUKASA c0a6858c42 Refactor V3Param (#2736)
* Use unique_ptr to manage lifetime. Slightly changed variable name. No functional change is intended.

* Let ParameterizedHierBlocks::areSame() public. No functional change is intended.
2021-01-03 07:21:45 +09:00
Yutetsu TAKATSUKASAandWilson Snyder 7a18adc716 Emit timescale in hierarchical block only when timescale is specified (#2735)
* Add a test for hierarchical verilation without timescale

* Emit timeunit in hierarchical wrapper only when it is specified in the input design or command line option.

* Update src/V3AstNodes.h

Co-authored-by: Wilson Snyder <[email protected]>

Co-authored-by: Wilson Snyder <[email protected]>
2021-01-02 08:31:27 +09:00
Wilson Snyder bd602d0e2d Copyright year update 2021-01-01 10:29:54 -05:00
Wilson Snyder 72b2df30f8 Fix tracing empty sc module (#2729). 2020-12-28 11:13:58 -05:00
Wilson Snyder d6c5d31dcd docker: Use sed to avoid perl 2020-12-23 19:23:23 -05:00
Wilson Snyder 84c323188e Internals: yapf reformat vlcovgen. No functional change. 2020-12-23 19:17:46 -05:00
Wilson Snyder cbd1bd5dad Tests: Fix some VPI coverage holes 2020-12-23 19:15:00 -05:00
Wilson Snyder 97255dc835 Tests: Test future if condition optimization (#2726) 2020-12-23 18:23:47 -05:00
Wilson Snyder 9f8b17230a Cleanup extra space on 'VlWide<...>>' 2020-12-23 18:09:12 -05:00
Wilson Snyder 93476a7372 Internals: Convert vlcovgen to python3. No functional change. 2020-12-23 16:54:05 -05:00
Wilson Snyder b8b9170f9d Remove Unix::Processors dependency 2020-12-23 16:07:14 -05:00
Wilson Snyder 575539996b Fix manifest for src/config_rev in last commit 2020-12-23 16:07:04 -05:00
Wilson Snyder 922eab5f93 Internals: Convert config_rev, cppcheck_filtered, flexfix to python3 2020-12-23 15:41:14 -05:00
Wilson Snyder b7a533109d Fix cppcheck warnings. No functional change intended. 2020-12-23 15:22:02 -05:00
Wilson Snyder 941e5c659a Fix cppcheck parse error 2020-12-23 15:22:02 -05:00
Unai Martinez-Corral e37a93bffb CI: (fix) check that CCACHE_DIR is set, before execing mkdir 2020-12-23 19:52:37 +01:00
Unai Martinez-CorralandWilson Snyder 6e3de7bfd1 CI: exploit concurrency (#2687)
Co-authored-by: Wilson Snyder <[email protected]>
2020-12-23 18:53:05 +01:00
Nandu Raj 1124829500 Fix $urandom_range maximum value (#2723) 2020-12-22 07:52:38 -05:00
Yutetsu TAKATSUKASA 4096dee598 Use files from gtkwave3-gtk3, not from gtkwave3 (#2718) 2020-12-21 07:06:03 +09:00
HyungKi Jeong 36f41e08a5 Fix to allow inheriting 'VerilatedVcdFile' class. (#2720) 2020-12-20 12:18:09 -05:00
Wilson Snyder 28ff71b1bf Internals: Misc refactoring from dcache branch. No functional change. 2020-12-19 20:46:10 -05:00
Wilson Snyder db276946b4 Internals: Convert internal code_coverage to python3. 2020-12-19 20:29:09 -05:00
Wilson Snyder beb03be731 Internals: convert install_test and dot_importer to python3. 2020-12-19 12:48:22 -05:00
Wilson Snyder b93e409f0e Optimize additional display statements (#2702). 2020-12-19 11:12:47 -05:00
Yutetsu TAKATSUKASA 788de3ad24 CI: Enable address sanitizer for vlt tests. (#2715) 2020-12-19 11:12:15 -05:00
Yutetsu TAKATSUKASA cb4ddd3213 Update files from GTKWave f119b35816e605e753fc1a24ae121a3787615b26 (#2716) 2020-12-19 09:13:18 -05:00
Wilson Snyder 7e94b3a4fa Examples: Explicitly refer to PYTHON3 not PYTHON 2020-12-18 23:07:21 -05:00
Wilson Snyder ca9bdc6e70 Tests: Ignore github action commits 2020-12-18 23:06:42 -05:00
github action 37ebc6e634 Apply clang-format 2020-12-19 03:55:46 +00:00
Wilson Snyder 457e926168 Use yapf3 and add to CI 2020-12-18 22:54:06 -05:00
Wilson Snyder ec4e408b2b Add yapf and reformat python code 2020-12-18 22:34:14 -05:00
Wilson Snyder a16ebaf79c Remove some stale and unsupported maintainer utilities 2020-12-18 21:57:48 -05:00
Wilson Snyder 1e34ae31d2 Fix vpi_release_handle to be called implicitly per IEEE (#2706). 2020-12-18 21:16:57 -05:00
Wilson Snyder 43811821d6 Backout GTKwave update 7deac509c6 2020-12-18 21:03:02 -05:00
Wilson Snyder 3797b5bca1 Check for vpi_release_handle even when no VL_DEBUG 2020-12-18 20:46:43 -05:00
Wilson Snyder 7deac509c6 GTKwave updates from upstream. 2020-12-18 19:33:57 -05:00
Wilson Snyder c39a8b439a Internals: Use emplace instead of insert(make_pair(...)). No functional change intended. 2020-12-18 18:24:47 -05:00
Wilson Snyder d0c4aee7b5 Tests: clang-format 2020-12-17 22:44:50 -05:00
Todd Strader a88965a124 Fix scope map for multiple construction (#2710) 2020-12-17 12:21:40 -05:00
James HanlonandJames Hanlon c18cbca813 Add support for package imports preceeding parameters in interfaces (#2714)
Co-authored-by: James Hanlon <[email protected]>
2020-12-17 11:26:53 -05:00
Yutetsu TAKATSUKASA e4eab56495 Add a workflow that calls clang-format and commit. (#2713)
* Add a workflow that calls clang-format and commit.
2020-12-17 23:41:10 +09:00
Wilson Snyder deb5531e54 Tests: Make explicit some IEEE-mandated freeing of VPI handles 2020-12-16 20:57:02 -05:00
Wilson Snyder 9bb353c577 Tests: Make explicit some IEEE-mandated freeing of VPI handles 2020-12-16 20:36:04 -05:00
Wilson Snyder a816c2b75e Tests: Fix hardcoded path in last test 2020-12-16 19:38:35 -05:00
Wilson Snyder ff702174d8 Report double calls to vpi_release_handle when using VL_DEBUG 2020-12-16 19:10:17 -05:00
Wilson Snyder d5d6598d75 Internals: spacing 2020-12-16 19:08:10 -05:00
Wilson Snyder 0abf18f618 Fix supporting begin_keywords 1364-2001-noconfig 2020-12-16 18:40:45 -05:00
Wilson Snyder 6adda241c9 Fix $urandom_range with no second argument 2020-12-16 18:34:49 -05:00
Yutetsu TAKATSUKASA ce9293fcb3 Fix memory leaks found in trace related tests (#2708)
* Fix memory leak of t_trace_cat and t_trace_cat_renew

* Fix memory leak of t_trace_c_api

* Fix memory leak in t_trace_public_func and t_trace_public_func_vlt

* Fix memory leaks in t_flat_build (and probably more).

* Use unique_ptr in testcases
2020-12-17 08:31:47 +09:00
Wilson Snyder d6168f654e Update contributor URL (#2711) 2020-12-16 18:02:54 -05:00
Yutetsu TAKATSUKASA 738ee3d4eb Fix memory leaks when using shared protect-lib (#2707)
* Guarantee mechanism to initialize just once is now in VerilatedInitializer. No functional change is intended.

* Make sure to initialize Verilated::NonInitialized just once. Fixes
memory leak in t_prot_lib_shared and t_hier_block_prot_lib_shared.

* Call setup() and teardown() of Verilated::NonSerialized.
2020-12-16 12:30:58 -05:00
Todd Strader b75901b3eb Fix VPI module tree (#2704) 2020-12-16 11:46:57 -05:00
Yutetsu TAKATSUKASA f98782c061 Tests: Fix use-after-free in fst testcases (#2709) 2020-12-16 10:00:13 -05:00
Wilson Snyder 3039735648 Tests: Fix various test leaks (#2703). 2020-12-15 23:12:13 -05:00
Wilson Snyder c00c26c705 Remove some comments emitted in output.
* Comments were disabling some optimizations.
* Suspect rarely referred to.
* Sometimes incorrectly placed due to other optimizations.
2020-12-15 22:55:17 -05:00
Wilson Snyder 084ba6711b Tests: Fix various test leaks (#2703). 2020-12-15 22:09:40 -05:00
Wilson Snyder c54360485e Fix over-iterating dpi dimensions (#2703). 2020-12-15 22:09:24 -05:00
Yutetsu TAKATSUKASA d9ef4ac435 Rename --asan to --sanitize (#2705) 2020-12-15 21:07:27 -05:00
Yutetsu TAKATSUKASAandWilson Snyder 176cc5a196 Add --asan option that enables address sanitizer to the test driver (#2700)
* Experimentally add --vltasan which enables address sanitizer

Co-authored-by: Wilson Snyder <[email protected]>
2020-12-16 07:33:26 +09:00
Yutetsu TAKATSUKASA 7821da6ad5 Fix DPI-C and protect-lib if port is implicit logic (#2699) 2020-12-15 09:51:14 -05:00
Wilson Snyder 5ee30e271e When combine functions, favor keeping non-slow name. 2020-12-13 21:53:55 -05:00
Wilson Snyder 4ce48788c5 Always use verilated_heavy (#2701).
On test suite adds ~7% runtime but will simplify logic and enable some
future changes.

Most large designs I saw were already using verilated_heavy as were using
strings, queues, associative arrays, classes, $readmem, $writemem, or
$valueplusargs.
2020-12-13 19:40:05 -05:00
Wilson Snyder 3590f7e206 Remove unused VL_DISABLE_INTRINSICS, use VL_PORTABLE_ONLY instead 2020-12-13 19:14:09 -05:00
Wilson Snyder 882b310897 Fix little endian packed array counting (#2499). 2020-12-13 16:23:59 -05:00
Wilson Snyder 82fc142c1c Add error on real to non-real output pins (#2690). 2020-12-13 13:33:48 -05:00
Wilson Snyder 5898c22b3b Internals: Cleanup variables for pin interconnection 2020-12-13 13:22:42 -05:00
Yutetsu TAKATSUKASA 13e88106da Internals:Cleanup dpiTypesToStringConverter. No functional change is intended. (#2698) 2020-12-13 16:05:06 +09:00
Marlon James 457d1a66f2 Fix VPI memory word indexing (#2695)
* Test that indexing into memory word fails

* VPI: don't index into memory word

Memory and memory words share a VerilatedVar, so check for memory word before attempting to index.
2020-12-12 22:47:47 -05:00
Wilson Snyder b04a1caeac In warnings, rename cells to instances to match IEEE 2020-12-12 22:43:55 -05:00
Wilson Snyder 53c4c7d540 Fix error format (#2095). 2020-12-12 22:26:50 -05:00
Wilson Snyder fb689bbb19 Fix clang warning, recent change 2020-12-12 22:16:10 -05:00
Wilson Snyder e2e3cc8463 Better error on inside on unpacked, queues, etc (#2566) 2020-12-12 21:20:42 -05:00
Wilson Snyder 6061744c4d Tests: Add t_dynarray_unpacked (#2314) 2020-12-12 20:56:35 -05:00
Wilson Snyder 8e25d2c61d Commentary (#2095). 2020-12-12 20:26:50 -05:00
Wilson Snyder 18f8c8a14f Fix error when dotted refers to missing module (#2095). 2020-12-12 20:25:00 -05:00
Wilson Snyder 44765e03a3 Internals: clang-format 2020-12-12 20:22:28 -05:00
Wilson Snyder 3f119f5647 Fix --no-decoration to turn off DPI import/export locations 2020-12-12 19:33:18 -05:00
Wilson Snyder 517fdb7587 Support queue of arrays 2020-12-12 19:19:32 -05:00
Wilson Snyder 0ca72f8098 For debug build, mv to prevent text busy error durring regression 2020-12-12 19:19:32 -05:00
Yutetsu TAKATSUKASA 28d139149a Test: Add unpacked array of 1 bit wire to DPI tests (#2694) 2020-12-13 07:28:37 +09:00
Wilson Snyder 81ce2cbc05 Internals: Params cleanups in prep for dedot. 2020-12-12 15:48:10 -05:00
Wilson Snyder d7af6436a2 Fix genblk naming to match IEEE (#2686). 2020-12-12 12:57:11 -05:00
Yutetsu TAKATSUKASA c80ca8d03e Test: Use non-blocking assignment as DRIVE macro does in t_prot_lib (#2693) 2020-12-12 23:07:12 +09:00
Wilson Snyder 93304f3b82 Internals: Reorder library code. No functional change. 2020-12-12 08:58:03 -05:00
Marlon James 30546afdab Fix VPI range iterator null return (#2691)
* Test that range iterator exhausts after 1 dimension

* Separate range iterator from range object

Range iterators should return NULL after all ranges have been returned
2020-12-12 08:11:08 -05:00
Wilson Snyder 82d8fe0c27 Internal coverage fixes 2020-12-10 22:01:56 -05:00
Wilson Snyder 4db673b2ff ci: Fix Ubuntu-18.04/16.04 runs 2020-12-10 20:22:00 -05:00
Wilson Snyder a5fa468343 Fix cast from packed structs, broke with $cast (#2684) 2020-12-10 18:36:06 -05:00
Wilson Snyder 2df1b72ce2 CI: Add separate contributors action (#2689) 2020-12-10 18:12:26 -05:00
Unai Martinez-Corral 2998890647 CI: remove unused 'ci-ccache-size.bash' (#2688) 2020-12-10 15:59:31 -05:00
Unai Martinez-Corral 8e178ca4a9 CI: Misc style cleanups (#2683) 2020-12-10 12:33:26 -05:00
Unai Martinez-Corral d94a8a28fa Fix Windows msys2, define WEXITSTATUS (#2685) 2020-12-10 12:20:54 -05:00
Unai Martinez-Corral 9a32158b5e CI: Cleanup ci/coverage to use a matrix to define coverage jobs (#2682)
* contributors: add Unai Martinez-Corral

* ci/coverage: use a matrix to define coverage jobs
2020-12-10 11:15:30 -05:00
Wilson Snyder b15dd3f898 Commentary 2020-12-10 09:06:01 -05:00
Wilson Snyder af0e535015 Internals: Remove Xnor node type.
Convert to Not(Xor(x)) up front, to help code coverage and optimize out extra nots sooner.
2020-12-10 00:04:10 -05:00
Wilson Snyder 5b2844e1be Fix instability in last commit from dangling deletes. 2020-12-09 23:57:40 -05:00
Wilson Snyder 53ce708294 Fix showing reference locations for BLKANDNBLK (#2170). 2020-12-09 23:07:11 -05:00
Wilson Snyder a1322635fd Internal coverage improvements 2020-12-09 22:32:09 -05:00
Wilson Snyder ab4ad9965c Fix DPI open array handling issues, and do internal coverage (#2350). 2020-12-09 22:15:34 -05:00
Wilson Snyder 2273fa62d9 CI: coverage action parallelism 2020-12-09 22:12:04 -05:00
Wilson Snyder cca874dc83 CI: coverage action parallelism 2020-12-09 21:35:48 -05:00
Wilson Snyder 274475aefd CI: coverage action parallelism 2020-12-09 21:33:22 -05:00
Wilson Snyder a91cf18d09 CI: coverage action parallelism 2020-12-09 21:30:31 -05:00
Wilson Snyder a7723ee9a5 CI: coverage action parallelism 2020-12-09 21:13:09 -05:00
Wilson Snyder 28ee80c310 CI: coverage action parallelism 2020-12-09 21:10:34 -05:00
Wilson Snyder 26da90ffce CI: coverage action parallelism 2020-12-09 20:57:17 -05:00
Wilson Snyder 9eb211a8d4 CI: coverage action parallelism 2020-12-09 20:55:01 -05:00
Wilson Snyder 75c2884fea CI: coverage action parallelism 2020-12-09 20:54:06 -05:00
Wilson Snyder f49f86c7ce CI: coverage action parallelism 2020-12-09 20:47:02 -05:00
Wilson Snyder a1989161d8 CI: coverage action parallelism 2020-12-09 20:38:41 -05:00
Wilson Snyder f11fa61ecf CI: coverage action parallelism 2020-12-09 20:37:11 -05:00
Wilson Snyder 9a904b97b2 CI: coverage action parallelism 2020-12-09 20:30:18 -05:00
Wilson Snyder 7d05be802d Misc internal coverage hole and related bug fixes 2020-12-09 19:18:12 -05:00
Krzysztof Bieganski 5e7b0d526d Support 'randc' as alias to 'rand' (#2680)
* Add alias 'randc' to 'rand'

* Make the 'RANDC' warning; add tests
2020-12-09 19:17:30 -05:00
Yutetsu TAKATSUKASA ff3d35ca61 Support unpacked array port in protect-lib and hierarchical verilation (#2672)
* Add a test to use unpacked array port in hierarchical verilation and protect-lib.

* V3EmitV supports unpacked array variables

* Can Emit local unpacked array properly

* Update golden of t_debug_emitv

* Support unpacked array port in protect-lib

* Remove t_prot_lib_unpacked_bad test as unpacked array is supported now.
2020-12-09 08:29:45 +09:00
Wilson Snyder c23de458ed Misc internal coverage cleanups 2020-12-08 08:40:22 -05:00
Wilson Snyder 90e0c9bdcd CI: internal coverage updates 2020-12-08 08:00:24 -05:00
Wilson Snyder 7892c5af13 Tests: Fix fstrobe instability 2020-12-08 07:49:48 -05:00
Wilson Snyder 0a0e4dce09 Internal coverage: default VERILATOR_ROOT setting. 2020-12-08 07:12:57 -05:00
Wilson Snyder 8e06b1e925 Misc internal coverage cleanups 2020-12-07 23:15:29 -05:00
Wilson Snyder a15540dfdd Tests: Add coverage github action 2020-12-07 21:57:10 -05:00
Wilson Snyder 3c680ddf22 Tests: Test some warnings without tests. 2020-12-07 20:30:16 -05:00
Wilson Snyder 47eeef485d Report UNUSED on parameters, localparam and genvars (#2627). 2020-12-07 19:49:50 -05:00
Wilson Snyder 251812638d Internals: Rename accessor. No functional change. 2020-12-07 18:50:31 -05:00
Krzysztof Bieganski cf7ea06b5d Support randomize() class method and rand 2020-12-07 17:55:22 -05:00
Wilson Snyder cd248f6bd7 Internals: Make consistent left/right/lo/hi accessors to ranges.
Change order of Range to store always left:right.
XML output changes to now show left:right (previously info was lost), no other change intended.
2020-12-06 21:13:56 -05:00
Wilson Snyder b32d530000 Error message cleanup 2020-12-06 20:33:08 -05:00
Wilson Snyder 570631380b Internal: Misc cleanups. No functional change intended. 2020-12-06 13:49:44 -05:00
Wilson Snyder d5f88cbf78 Tests: Rename some tests. 2020-12-06 11:37:56 -05:00
Wilson Snyder 74ef35d3b3 Support $cast and new CASTCONST warning. 2020-12-05 22:58:36 -05:00
Wilson Snyder 8b8ebb0e43 Internals: Use restorer. No functional change. 2020-12-05 22:21:30 -05:00
Yutetsu TAKATSUKASA 301b4ff1ad Internals: Introduce TaskDpiUtils in V3Task (#2670)
* Internals:Simplify V3Task.cpp. no functional change intended

* Internals:Introduce TaskDpiUtils in V3Task.cpp. No functional change intended
2020-12-06 12:09:48 +09:00
Yutetsu TAKATSUKASA 5476ff93e2 Ignore some files generated by modelsim (#2669) 2020-12-05 21:55:56 -05:00
Yutetsu TAKATSUKASA 375ea169b9 Internals: Apply verilog-mode. No functional change is intended. (#2671) 2020-12-05 21:55:06 -05:00
Wilson Snyder 9c2785b49b Internals: Swap lhs/rhs $cast args. 2020-12-05 17:11:00 -05:00
Wilson Snyder 8582aed66a Add --top option as alias of --top-module. 2020-12-05 16:58:17 -05:00
Wilson Snyder 9bd5cd4ef3 Internals: Track null separately from '0 2020-12-05 16:49:10 -05:00
Wilson Snyder f858dd44ac Fix :: references to forward classes 2020-12-05 16:23:20 -05:00
Wilson Snyder e69736124f Debug: Less verbose link. 2020-12-05 16:16:37 -05:00
Wilson Snyder f0e691a1b8 Handle unsupported parameters through link phase 2020-12-05 11:30:14 -05:00
Wilson Snyder 5fb834e41e Fix passing parameter type instantiations by position number. 2020-12-05 11:00:30 -05:00
Yutetsu TAKATSUKASA 7f6d4ac359 Use both gcc and clang in CI (#2667)
* Remove remaining TRAVIS_ variable

* Use both gcc and clang.
2020-12-05 12:36:04 +09:00
Wilson Snyder 666d0ab552 Standard YAML spacing is 2 spaces. 2020-12-04 17:39:53 -05:00
Wilson Snyder b9f2400d17 Rename workflow to appease badges 2020-12-04 17:11:00 -05:00
Wilson Snyder 85b2c6b6c7 Github actions badge fix 2020-12-04 17:06:18 -05:00
Yutetsu TAKATSUKASAandWilson Snyder 73a7595335 Add the initial version of CI using GitHub Actions (#2665)
* Add the initial version of CI using GitHub Actions

* Update .github/workflows/check_pr.yml

Co-authored-by: Wilson Snyder <[email protected]>

* remove setting for travis

* rename travis-*.bash to ci-*.bash

* Rename TRAVIS_ variables to CI_

* install ccache and libsystemc(-dev) in ci-install.bash

* Use CI_ variables and Ubuntu-20.04 that provides SystemC

* call ccache maintenance

Co-authored-by: Wilson Snyder <[email protected]>
2020-12-05 00:30:46 +09:00
Wilson Snyder 38c6085f54 devel release 2020-12-02 20:19:04 -05:00
Wilson Snyder b350b6a0ff Version bump 2020-12-02 20:09:23 -05:00
Wilson Snyder 80564a8f89 Remove vgen test to avoid Bit::Vector for testing. 2020-12-02 20:06:07 -05:00
Yuri Victorovich 016611021d Fix the default GNU Make executable name on FreeBSD (#2553) 2020-12-02 19:27:53 -05:00
Wilson Snyder fa20614277 Fix Ubuntu 16.04 LTS warning 2020-12-02 19:20:03 -05:00
Wilson Snyder 1e69167191 Internals: Move function in V3Width. No functional change. 2020-12-02 18:51:29 -05:00
Wilson Snyder faa5edc068 Add TspStateBase destructor (#2620). 2020-12-02 07:37:34 -05:00
Wilson Snyder e3c32adad4 Rename static/thread misnamed variables. No functional change. 2020-12-01 19:32:01 -05:00
Wilson Snyder b054d937cb Rename static/thread misnamed variables. No functional change. 2020-12-01 19:01:20 -05:00
Wilson Snyder 212e8fb14b Internals: Cleanup some inlines, use constexpr. No functional change intended. 2020-12-01 18:49:03 -05:00
Wilson Snyder 014e43f0ef Reset index counts on clearing verilated_cov (static removal) 2020-12-01 18:30:25 -05:00
Wilson Snyder d21b4e3fc7 Internal cast preparatory cleanups. 2020-11-29 18:26:06 -05:00
Wilson Snyder 0818d88113 Tests: Cast enum test 2020-11-29 16:59:08 -05:00
Wilson Snyder 77ec2dc875 Internals: Rename some CI comments 2020-11-29 15:06:29 -05:00
Wilson Snyder 665e8edaff Support $monitor and $strobe. 2020-11-29 11:31:38 -05:00
Wilson Snyder 67103d346b Fix $fwriteh/$fwriteo 2020-11-29 10:53:44 -05:00
Wilson Snyder aebb54444e Internals: Favor NodeProcedure. No functional change intended. 2020-11-29 09:50:30 -05:00
Wilson Snyder a54ac52a35 Internals: Use 'Bit' where mean 2-state type. No functional change. 2020-11-29 08:23:36 -05:00
Wilson Snyder aa360052a8 Internals: Code movement, no functional change. 2020-11-28 22:01:11 -05:00
Wilson Snyder e09f039a36 Internals: Remove dead code. No functional change. 2020-11-28 21:43:37 -05:00
Wilson Snyder ff262fc4fb Support type(t) static casting 2020-11-28 17:29:21 -05:00
Wilson Snyder 9a9931fb9d Support complex function arguments. 2020-11-28 13:46:14 -05:00
Wilson Snyder 30686d8550 Support passing of objects to functions 2020-11-28 12:43:24 -05:00
Wilson Snyder 05f3fd7c6e Fix class new with math. 2020-11-28 12:26:44 -05:00
Wilson Snyder e14319b401 Internals: Refactor V3Param through code movement only. No functional change intended. 2020-11-28 12:04:29 -05:00
Wilson Snyder 1299b70945 Internals: Pass class parameters through link. 2020-11-27 22:48:42 -05:00
Wilson Snyder cf2810db8b Change -sv option to select 1800-2017 instead of 1800-2005. 2020-11-27 21:49:47 -05:00
Wilson Snyder d77beecc6e Fix $countbits(..., 'z) 2020-11-27 21:34:40 -05:00
Wilson Snyder 0c6bd42da3 Fix $countbits(..., 'x) 2020-11-27 20:51:32 -05:00
Wilson Snyder 5091298fae Internals: Cleanup V3Unknown. No functional change intended. 2020-11-27 20:25:02 -05:00
Wilson Snyder cef7610b14 Fix crash on virtual interfaces. 2020-11-27 20:02:17 -05:00
Wilson Snyder ed268805ce Lint check for pure virtual in non-virtual class. 2020-11-27 19:53:04 -05:00
Wilson Snyder 123d1af29d Fix crash on non-class static function 2020-11-27 14:58:50 -05:00
Wilson Snyder cc307626c0 Tests: Add class name test. 2020-11-27 10:34:31 -05:00
Wilson Snyder 963fd0664d Fix class-in-module issues 2020-11-27 09:42:51 -05:00
Wilson Snyder 4643d6e883 Internals: Refactor V3Param through code movement only. No functional change intended. 2020-11-27 09:17:44 -05:00
Wilson Snyder d89fc05da1 Internals: Refactor V3Param through code movement only. No functional change intended. 2020-11-27 09:04:56 -05:00
Wilson Snyder 84d7380588 Internals: Param immediate delete, in prep for next commit. No functional change intended. 2020-11-27 08:50:29 -05:00
Wilson Snyder 04febb1944 Internals: Move V3Param code. No functional change. 2020-11-26 15:03:55 -05:00
Wilson Snyder d56b923eaa Fix 'randomize() with {}' crash 2020-11-26 11:50:50 -05:00
Wilson Snyder a37866ee92 Support 'super'. 2020-11-26 11:06:59 -05:00
Wilson Snyder 1a92a44c7d Internals: Assert on misexpected 'new'. 2020-11-26 09:38:47 -05:00
Wilson Snyder 60a1d25a96 Fix extern function member references. 2020-11-26 08:55:32 -05:00
Wilson Snyder ad21f2e850 Fix 'this' in extern functions. 2020-11-26 08:28:53 -05:00
Wilson Snyder ffbae97a3d Tests: Make t_lint_syncasyncnet_bad etc tolerate -Oi. 2020-11-25 21:54:50 -05:00
Wilson Snyder 380137a402 Fix internal pointer shown on CLKDATA warnings 2020-11-25 21:34:56 -05:00
Wilson Snyder ac2058c7ec Tests: Fix t_unopt_combo_waive with -Oi 2020-11-25 21:18:13 -05:00
Wilson Snyder de931d6a97 Fix LHS is not a lvalue when using tristate with -Oi. 2020-11-25 21:09:25 -05:00
Wilson Snyder f2d8e45d72 For performance, use unordered_set/map where possible. No functional change intended. 2020-11-25 20:57:30 -05:00
Wilson Snyder 085ef5fc05 Fix extern function var refs getting errors. 2020-11-25 20:05:44 -05:00
Wilson Snyder 6095efd84e Check for proper 'local' and 'protected' (#2228). 2020-11-25 07:03:01 -05:00
Wilson Snyder 114ab1378f Internals: Track class package on membersels 2020-11-24 23:36:09 -05:00
Wilson Snyder 8622c754b7 Fix unstable statistic 2020-11-24 23:35:44 -05:00
Wilson Snyder bf24fa9478 Fix access to non-overridden base class variable (#2654). 2020-11-24 22:46:02 -05:00
Wilson Snyder e1c45440fc Internals: Rename packagep(). No functional change. 2020-11-24 21:56:03 -05:00
Wilson Snyder b0cb43b2f2 Fix not iterating some extended classes depending on declaration order. 2020-11-24 21:41:32 -05:00
Wilson Snyder dc1f44840d Internals: Fix not clearing packagep on some assignments. Should affect assertions only. 2020-11-24 21:34:11 -05:00
Wilson Snyder fd21a41acd Internals: Minor cleanups before class fix (#2654). No functional change intended. 2020-11-24 21:28:26 -05:00
Wilson Snyder cf09a9b6d2 Commentary 2020-11-24 18:45:36 -05:00
Wilson Snyder dc306cf371 Internal debug: avoid segflt with gdb "pnt" 2020-11-24 18:35:12 -05:00
Wilson Snyder 35374f09b4 Add error on class extending itself 2020-11-24 18:15:49 -05:00
Wilson Snyder e85a2e860e Support 'with item.index'. 2020-11-23 23:18:58 -05:00
Wilson Snyder 103ba1fb6d Commentary 2020-11-20 21:48:11 -05:00
Wilson Snyder b684995292 Support $random and $urandom seeds. 2020-11-19 21:32:33 -05:00
Wilson Snyder c371a63d41 Internals: Fix missing final. No functional change. 2020-11-19 08:23:15 -05:00
Yutetsu TAKATSUKASA 0102efd4ea Support unpacked array in DPI-C (#2648)
* Add tests for unpacked array in DPI-C

* Add more generic parameter generator to AstNodes

* Supports multi dimensional array in DPI ( DPI argmuments <=> Verilator internal type conversion)

consider typedef in V3Task

fix export test

fix inout for scalar

support export func of time

* V3Premit does not show an error for wide words nor ArraySel

* Unnecessary pack func for unapcked array does not appear anymore

* Support unpacked array in runtime header

- Add an overload for lvalue VL_CVT_PACK_STR_NN
- Allow conversion from void *

* touch up tests for codacy advices

* resolve free functions. no functional change intended.
2020-11-19 22:02:58 +09:00
Wilson Snyder abfee1270f Improve internal code coverage 2020-11-18 22:21:48 -05:00
Wilson Snyder 5992d678be Fix clang error, broke last commit. 2020-11-18 22:18:29 -05:00
Wilson Snyder b6ded59c2b Internals: Use and enforce class final for ~5% performance boost. 2020-11-18 21:32:16 -05:00
Wilson Snyder c0888c1b0f Internals: Use newline instead of endl to avoid unneeded flush. 2020-11-18 21:03:23 -05:00
Wilson Snyder fa77141519 Fix unpacked array parameters near functions (#2639). 2020-11-18 20:12:14 -05:00
Wilson Snyder b3760911e7 Internals: Param minor cleanups. No functional change intended. 2020-11-18 19:50:47 -05:00
Yutetsu TAKATSUKASA b500e57991 Add an overload of VL_CVT_PACK_STR_NN for lvalue (#2651) 2020-11-19 06:52:03 +09:00
Yutetsu TAKATSUKASA 19e4013ab5 Allow conversion from const void * to QData (#2650) 2020-11-18 23:44:45 +09:00
Wilson Snyder 82b2af3b83 Commentary 2020-11-17 22:48:37 -05:00
Wilson Snyder e6f7510895 Add check for rand_mode/constraint_mode. 2020-11-17 22:14:18 -05:00
Wilson Snyder 2f718b9ea0 Show IEEE reference in array port message, plus internal cleanups. 2020-11-17 21:10:50 -05:00
Marlon James 899e7bacb2 Fix VPI callback list iteration (#2644)
The end iterator always points to an element past the end of the list.
When new elements are added to the back of the list, they are inserted
before the end iterator.
Instead, track the last element in the list at the start of processing
and stop after it's been processed.
2020-11-17 17:19:51 -05:00
Tomasz Gorochowik 5b3717b369 Tests: Memory clean up in tests (#2645)
This patch normalizes what the tests do before exiting. After this
change each test should call final on the top module and explicitly
free the top module object before exiting.
2020-11-17 06:37:55 -05:00
Wilson Snyder 1e7c61b23e Internals: Refactor huge func in V3Param. No functional change intended. 2020-11-16 22:35:51 -05:00
Marlon James 0e1e380a55 Fix test for callCbs() so it can fail (#2613) 2020-11-16 21:00:09 -05:00
Wilson Snyder 1b0a48ea02 Internals: Use C++11 = default where obvious. No functional change intended. 2020-11-16 19:56:16 -05:00
Wilson Snyder 70b3a599ce Fix trace signal names getting hashed (#2643). 2020-11-16 18:11:27 -05:00
Wilson Snyder 26c0e6ba00 Fix missing array include. 2020-11-16 07:31:12 -05:00
Wilson Snyder efc6fb7fc3 Internals: Better pack AstNode. No functional change. 2020-11-15 22:03:06 -05:00
Wilson Snyder b68038a73f clang-tidy fix. No functional change. 2020-11-15 17:23:02 -05:00
Wilson Snyder f4ef4ad9f3 Internals: Favor std::array where easy. No functional change intended. 2020-11-15 16:21:26 -05:00
Wilson Snyder f6f7684ccd Internal member initialization. No functional change intended. 2020-11-15 15:40:35 -05:00
Wilson Snyder e74cc32f2d Add internal assertion that VarScopes properly formed. 2020-11-14 16:13:06 -05:00
Wilson Snyder c64cc989f0 verilator_gantt: Show CPU physical info. 2020-11-14 12:22:15 -05:00
Wilson Snyder f94fcaa8e4 Move YYDEBUG into header. No functional change intended. 2020-11-14 10:20:27 -05:00
Wilson Snyder 297b297bc7 devel release 2020-11-14 10:00:01 -05:00
Wilson Snyder 02cb3d17a2 Version bump 2020-11-14 09:50:30 -05:00
Wilson Snyder c3cfaf55ed Commentary 2020-11-14 09:26:38 -05:00
Wilson Snyder 3e7013af31 Internal scope cleanup. No functional change. 2020-11-13 21:12:18 -05:00
Wilson Snyder f7a5883205 Internals: assert not double adding. No functional change intended. 2020-11-13 21:12:03 -05:00
Wilson Snyder 5d3482734a Fix precision in verilator_gantt. 2020-11-13 18:51:45 -05:00
Yutetsu TAKATSUKASA e8c03650ae Fix internal error if always block without begin-end has concat (#2640) (#2641) 2020-11-13 09:50:09 -05:00
Wilson Snyder 7eac788306 Add error on using :: with module 2020-11-12 19:45:26 -05:00
Wilson Snyder 6a58e67699 Commentary 2020-11-12 19:31:53 -05:00
Wilson Snyder b49be06a5a Tests: Standard wording. 2020-11-12 18:50:05 -05:00
Wilson Snyder 87b2adb6a1 With --debug, turn off address space layout randomization. 2020-11-12 18:49:49 -05:00
Wilson Snyder 5634a18f78 Tests: Smaller t_vpi_var test 2020-11-11 20:57:24 -05:00
Wilson Snyder b84c9bb4c0 Internals: Show scope debug information. 2020-11-11 19:00:10 -05:00
Wilson Snyder 6dfce882a1 Support $exit as alias of $finish 2020-11-10 22:49:48 -05:00
Wilson Snyder 79d33bf1ee Use C++11 for loops, from clang-migrate. No functional change intended 2020-11-10 22:10:38 -05:00
Wilson Snyder 44eb362a18 clang-tidy cleanups. No functional change intended. 2020-11-10 21:40:14 -05:00
Wilson Snyder 8664aac225 Fix missing newlines in emit. 2020-11-09 18:29:09 -05:00
Wilson Snyder 6965e138aa Add clearer unsupported message for inside on array (#2566) 2020-11-08 23:26:58 -05:00
Wilson Snyder fc52fb9093 Fix arrays of modport interfaces (#2614). 2020-11-08 22:43:32 -05:00
Wilson Snyder cef7708f38 Internals: Fix missed access change. No functional change intended. 2020-11-08 22:02:35 -05:00
Dan Petrisko 438fb01665 Fix exited typo (#2634) 2020-11-08 21:55:33 -05:00
Wilson Snyder 67d5b1a11a Internals: Preserve arrays of modports. Part of #2614. 2020-11-08 19:15:53 -05:00
Wilson Snyder d78941885b Fix cast width propagation (#2597). 2020-11-08 19:07:33 -05:00
Wilson Snyder 6e7b07c794 Internals: Prep for #2597. No functional change intended 2020-11-08 18:58:31 -05:00
Wilson Snyder 9655e287ab Tests: Travis regression fix 2020-11-08 17:06:03 -05:00
Wilson Snyder 917ca2bad7 Tests: Add t_const_opt_red (#2632) (#2633) 2020-11-08 16:39:28 -05:00
Wilson Snyder c3f5dd7414 Tests: Try to stabilize cron test. 2020-11-08 11:17:42 -05:00
Wilson Snyder 04c7fd1696 Tests: Add wire-or mux test for future optimization. 2020-11-07 21:57:31 -05:00
Wilson Snyder 152689776d Report error on typedef referencing self (#2539). 2020-11-07 15:41:37 -05:00
Wilson Snyder 778f133118 Fix dynamic new with init argument (#2325). 2020-11-07 14:28:05 -05:00
Wilson Snyder ff5465308b Internals: Tree dump DEFAULT pattern. No functional change. 2020-11-07 11:56:24 -05:00
Wilson Snyder 602750b1ee Commentary 2020-11-07 10:49:54 -05:00
Wilson Snyder 2a24bb4759 Fix queue poping wrong value when otherwise unused (#2512). 2020-11-07 10:37:55 -05:00
Krzysztof Bieganski 7c4259bc0a Support static methods and typedefs in classes (#2615) 2020-11-06 19:51:21 -05:00
Kaleb Barrett 1c2384cb3d Fix iteration over mutating list bug in VPI impl (#2588)
Previously, in any given VPI callback, if the callback body registered
the same callback, that registering would be processed in the currently
executing call to the call*Cbs function. In the worse case, this could
lead to an infinite loop.
2020-11-06 17:56:15 -05:00
Yutetsu TAKATSUKASAandWilson Snyder 75881754a9 Fix dangling reference (Issue #2622) (#2623)
* collect multiple string literals of "__Vcvt". No functional change is intended.

* temporary variable for DPI-C should be static if its type is string

* Update src/V3EmitC.cpp

Co-authored-by: Wilson Snyder <[email protected]>

Co-authored-by: Wilson Snyder <[email protected]>
2020-11-04 06:08:03 +09:00
Wilson Snyder 0505816d31 Fix C++14 deprecated random_shuffle. 2020-11-03 08:52:47 -05:00
Wilson Snyder 48bcf66ac7 Fix C++14 deprecated random_shuffle. 2020-11-02 20:07:58 -05:00
Wilson Snyder 0145d9d514 Fix C++14 deprecated random_shuffle. 2020-11-02 19:55:01 -05:00
Wilson Snyder 2ce86eddfa Internal debug. No functional change. 2020-11-01 22:27:27 -05:00
Wilson Snyder b663d1a230 Rename internal interface references, part of #2614. 2020-11-01 20:52:21 -05:00
Wilson Snyder 5821048df7 Fix clang warning. 2020-11-01 17:18:06 -05:00
Wilson Snyder 80284c437e Internals: Refactor some VAssign printing. No functional change. 2020-11-01 16:59:23 -05:00
Wilson Snyder 2aedc91151 Support queue and associative array 'with' statements. (#2616) 2020-11-01 10:56:07 -05:00
Wilson Snyder c1e8337fc1 Support pattern assignment to dynamic arrays. 2020-11-01 10:18:32 -05:00
Wilson Snyder 1858cc8ff1 Fix test stability due to #2618. 2020-11-01 09:26:55 -05:00
Wilson Snyder 5e6aca59ab Fix test stability due to #2618. 2020-11-01 09:14:45 -05:00
Wilson Snyder 726e78fdda Add 'with' syntax checks. 2020-10-31 10:33:36 -04:00
Wilson Snyder 085e8454b8 Support 'with' into elaboration (only). 2020-10-31 10:00:55 -04:00
Wilson Snyder 85b05366bc Internals: Misc prep work for 'with' support. 2020-10-31 09:24:16 -04:00
Wilson Snyder e6b0479b80 Internals: CFunc VL_RESTORER. No functional change intended. 2020-10-31 09:14:47 -04:00
Wilson Snyder 3a53b32a32 Move queue code before assoc, as assoc will eventually use queues. No functional change. 2020-10-30 22:49:55 -04:00
Wilson Snyder cf7b5c091a Internals: Track some VAccess that can be ReadOnly. No functional change. 2020-10-30 22:28:51 -04:00
Wilson Snyder 51b0963e61 Internals: Favor const for map keys. No functional change intended. 2020-10-30 18:00:40 -04:00
Wilson Snyder 0c949ceba2 Internals: classOrPackage is a module, from #2615. 2020-10-30 08:43:20 -04:00
Wilson Snyder 5c070558ae Internals: Misc cleanups in prep for interface bugfix. No functional change intended. 2020-10-29 21:27:19 -04:00
Wilson Snyder 0c328b6eaf clang-format of test_regress. No functional change. 2020-10-28 18:42:36 -04:00
Wilson Snyder f670eccf8c Tests: $countbits 2020-10-28 07:39:13 -04:00
Wilson Snyder 23140aeff0 Internals: V3Begin code cleanup. No functional change. 2020-10-27 22:39:45 -04:00
Wilson Snyder d44426b3f3 clang-format. No functional change. 2020-10-27 20:33:45 -04:00
Yutetsu TAKATSUKASA 05ff96bea3 Fix SEGV when $fgets, $sscanf, or $fscanf is used with string (#2604)
* Add a test to use string for $fgets

* Use dedicated function for $fgets to std::string

* share the implementation of $fgets

* Pass -1 for bitwidth of std::string to distinguish from POD

* add checks for scanf with string

* apply clang-format
2020-10-28 08:37:12 +09:00
Jean Berniolles 77ac9bfcc6 Fix WIFEXITED missing from MinGW/MSYS2 (#2609)
* WIFEXITED missing from MinGW/MSYS2, added defines

* Found source of the WIFEXITED macro in the binutils-gdb repo. Now with less pointer manipulation.
2020-10-27 13:33:25 -04:00
Marlon James 34b8ed4cf0 Return bool from callValueCbs() (#2589) (#2605)
* Return bool from callValueCbs()

Returns true if any registered callback was called, else false.

* Add test for callCbs() and callValueCbs()
2020-10-26 21:55:27 -04:00
Wilson Snyder 95d1272269 Support associative array pattern assignments and defaults. 2020-10-25 21:05:22 -04:00
Wilson Snyder 046c0a7aa1 Fix queue assignment with different limits, negative indicies 2020-10-24 22:08:11 -04:00
Wilson Snyder 835905bdae Convert cast tasks to assertions 2020-10-24 20:30:52 -04:00
Wilson Snyder 51d1235cda Shorter stringify of empty queues, and better queue tests 2020-10-24 18:00:40 -04:00
Wilson Snyder 2f21b3385a Tests: Casting. 2020-10-24 17:46:09 -04:00
Wilson Snyder 9d0a7d5e70 Commentary (#2606). 2020-10-23 18:30:10 -04:00
Wilson Snyder 4cec3ff2a0 Fix WIDTH warnings on comparisons with nullptr (#2602). 2020-10-22 17:27:23 -04:00
Wilson Snyder 25593c0ee2 Fix capitalization 2020-10-22 17:13:42 -04:00
Wilson Snyder 5d3dd52f13 Support queue slicing (#2326). 2020-10-18 13:23:39 -04:00
Wilson Snyder ec36d0d772 Internals: When resolving assignments pass dtype to children. 2020-10-18 12:30:33 -04:00
Wilson Snyder 3d2503f9aa Tests: Run execute on non-Verilator when unsupported test. 2020-10-17 21:31:58 -04:00
Wilson Snyder 4576644591 Prep for future queue slicing. 2020-10-17 21:09:10 -04:00
Wilson Snyder d8df216a8d Fix emit indent of VL_TO_STRING 2020-10-17 20:05:21 -04:00
Wilson Snyder 964dcd5b7c Tests: Add additional array method tests and error 2020-10-17 19:23:27 -04:00
Wilson Snyder f62c070d06 Internals: Concat strings only when final; prep for queues. 2020-10-17 18:56:38 -04:00
Wilson Snyder a56e0a6e89 Internals: Prep for type method. No functional change intended. 2020-10-17 16:48:11 -04:00
Wilson Snyder 451e961e03 Internals: Prep for type method. No functional change intended. 2020-10-17 16:04:29 -04:00
Wilson Snyder cb550e5357 Remove old MSVC 6 workarounds 2020-10-17 14:21:27 -04:00
Wilson Snyder 829db3eefa Fix tick style on %p formats. 2020-10-16 19:26:04 -04:00
Wilson Snyder 44f938e507 Use static const for emitted parameter declarations. 2020-10-16 19:05:28 -04:00
Wilson Snyder 4849c0530b Fix class extends with typedef. 2020-10-16 18:25:32 -04:00
Wilson Snyder f4ed367850 Internals: Remove verilator_difftree old cleanups. 2020-10-15 21:36:35 -04:00
Wilson Snyder d4df94d866 Internals: Move static resolution to LinkParse. 2020-10-15 21:08:24 -04:00
Wilson Snyder 5d8019f941 Internals: Only need to applyFTask once. No functional change intended. 2020-10-15 21:02:24 -04:00
Wilson Snyder 48597bebaf Tests: Better static tests 2020-10-15 20:44:51 -04:00
Wilson Snyder 470859f929 devel release 2020-10-15 08:26:36 -04:00
Wilson Snyder 77553d23fc Version bump 2020-10-15 08:21:57 -04:00
Wilson Snyder 3b9c8b64f7 Tests: Add unsupported queue method/slice testing. 2020-10-14 21:57:53 -04:00
Wilson Snyder 7e5f562500 Tests: Use internal sed as external croaks on binary. 2020-10-14 09:30:15 -04:00
Wilson Snyder d4d3ae4dfc Fix compile error. 2020-10-14 07:31:22 -04:00
Wilson Snyder 79b1b07fcd Commentary 2020-10-14 07:30:15 -04:00
Wilson Snyder e3cf5c07e4 Internal coverage improvements. No functional change. 2020-10-13 21:13:52 -04:00
Wilson Snyder 8750352495 Internal coverage: Cleanup some savable errors and coverage. 2020-10-13 19:26:16 -04:00
Wilson Snyder 3d8dc2774b Fix clang 11 warning. No functional change intended. 2020-10-13 19:22:49 -04:00
Markus Krause 0a9ae154be introduce define for FST tracing (#2592)
This is to allow C++ verilator toplevel to support
multiple modes of waveform tracing
VM_TRACE_FST can be used inside a #if VM_TRACE
section to switch between classic .vcd tracing and the
more compact .fst format supported by GTKWAVE
2020-10-10 21:17:39 -04:00
Wilson Snyder e25a6334cf Support repeated forward typedefs. 2020-10-10 11:29:10 -04:00
Wilson Snyder 070bead9f9 Internals: Refector typedef call. No functional change intended. 2020-10-10 11:25:44 -04:00
Wilson Snyder 549921be2e Disable Free BSD under travis. (#2591) 2020-10-10 09:49:50 -04:00
Wilson Snyder 7c05033b79 Add verilator_gantt warning when too few cpus (#2590) 2020-10-09 21:28:00 -04:00
Wilson Snyder 215d3614c0 Fix preprocessor stringify of undefined macro. 2020-10-09 18:53:09 -04:00
Wilson Snyder 1ebf937a6c Internals: Favor std method. No functional change intended. 2020-10-09 17:55:58 -04:00
Rafal Kapuscik 7be343fd7c Support 'this' (#2585). 2020-10-08 07:54:01 -04:00
Wilson Snyder fb2d78520f Internals: Remove redundant initial clears. No functional change intended. 2020-10-07 19:43:08 -04:00
Yutetsu TAKATSUKASA c5da072ff6 Fix performance degradation when --threads is used with --hierarchical (Issue #2562) #2581 2020-10-05 08:20:49 +09:00
Wilson Snyder efbcb094ca Fix flushCall for backward compatibility (#2580). 2020-10-04 07:47:25 -04:00
Wilson Snyder 5033c906fd Commentary (#2577) 2020-09-30 16:55:26 -04:00
Wilson Snyder f8ab30d127 Commentary (#2575) 2020-09-28 08:45:50 -04:00
Victor Besyakov 222ca4b009 Tests: Add t_stream_integer_type (#2547) (#2548) (#2573) 2020-09-27 19:25:53 -04:00
James Pallister e3a1954e20 Fix hierarchical references used inside a function (#2267) (#2572) 2020-09-27 10:10:44 -04:00
Wilson Snyder 4ba2637360 Fix class wide member display (#2567). 2020-09-25 07:37:38 -04:00
Wilson Snyder 6430743b6f Fix method calls to package class functions (#2565). [Peter Monsson] 2020-09-22 09:09:10 -04:00
Wilson Snyder 0c49cca527 Fix $urandom_range passed variable (#2563). 2020-09-22 08:44:51 -04:00
Wilson Snyder 7a9e79ea79 Fix -G dropping public indication (#2561). 2020-09-21 08:29:57 -04:00
Yutetsu TAKATSUKASA 157948c552 Fix cmake build with --hierarchical option (#2560)
* hier_block with cmake test doesn't assume prefix now.

* Add space between files

* don't set -Mdir on cmake build as it will be set by DIRECTORY option

* Use top target name instead of prefix
2020-09-20 07:48:05 +09:00
Wilson Snyder 1a127a479c Internal coverage improvements 2020-09-19 10:30:31 -04:00
Wilson Snyder 87e4a86fbb Internal coverage improvements 2020-09-18 21:27:36 -04:00
Yutetsu TAKATSUKASA 1c1b95161b Load source file of the hier_block explicitly (#2559)
* Add a test to make sure that lib modules (loaded via -y option) can be a hier_block.

* Add HDL file of the hier_block to the source list if the module is loaded via -y option.

(Each hier_block is treated as a top module when processing the hier_block.)

* Use "\n" for delimiter as the other files
2020-09-19 08:13:49 +09:00
Wilson Snyder 66d1754d19 Fix constant x propagation of xor. 2020-09-18 17:47:22 -04:00
Piotr Binkowski 57a53c014d Internals: Add proper delegation to dump methods (#2555) 2020-09-16 21:52:24 -04:00
Yutetsu TAKATSUKASA e48a859b86 Add timescale directive for hier_block if the original design has it (#2554)
* add timescale directive to a test to reproduce #2544

* add timescale directive to hierarchy blocks
2020-09-17 06:09:29 +09:00
Wilson Snyder 430238a6b4 Support # as a comment in -f files (#2497). 2020-09-15 20:12:08 -04:00
Wilson Snyder 9a4c5509fc Internals: Allow make clang-format in src 2020-09-15 07:39:50 -04:00
Wilson Snyder 0765443353 Internals: Remove unneeded constructor. 2020-09-15 07:35:53 -04:00
Yuri Victorovich d07a6f81e4 Fix cmake-based verilated rebuilds (#2543) 2020-09-11 13:07:00 -04:00
Wilson Snyder fac04521db Internals: Fix VL_LEAK_CHECK (#2542). 2020-09-11 11:52:30 -04:00
Peter Monsson d0819f156f Add support for |=> inside properties (#1292). 2020-09-10 06:49:04 -04:00
Wilson Snyder b77eab3f83 Fix crash when mismatching queue types. 2020-09-07 21:13:38 -04:00
Wilson Snyder 30f3774134 Support const object new() assignments. 2020-09-07 17:26:53 -04:00
Wilson Snyder 1899a875a4 Internals: Create VAccess class. No functional change intended. 2020-09-07 17:09:25 -04:00
Wilson Snyder cc134b38ee Internal coverage: Misc cleanups 2020-09-07 13:11:44 -04:00
Wilson Snyder 993115d30a Cleanup and test EmitV for internal coverage 2020-09-07 12:58:30 -04:00
Wilson Snyder c1d35c8622 devel release 2020-09-07 09:42:13 -04:00
Wilson Snyder 16fba59480 Version bump 2020-09-07 09:26:03 -04:00
Wilson Snyder 4266c789ce Commentary 2020-09-07 09:20:17 -04:00
Peter Monsson 627d83e807 Add support for assume property (#2531) 2020-09-03 12:38:48 -04:00
Peter Monsson 80f5738544 Tests: Move t_rose t_fell and t_stable to a single test (#2530) 2020-09-03 08:09:47 -04:00
Wilson Snyder 600641b4a1 Tests: Add process test #2527 2020-08-31 19:02:58 -04:00
Yutetsu TAKATSUKASA 70eb99b050 Fix double-free on shared protect-lib (#2526)
* Add a test to use shared object of protect-lib
* Add a guard to call ctor/dtor just once even when a protec-lib is shared object.
* Pass .a to linker in leaf-last order for older ld.
* Add -flat_namespace for mac
2020-08-31 08:22:31 -04:00
Wilson Snyder dc1ad16b03 Travis: Try install twice 2020-08-30 17:34:25 -04:00
Wilson Snyder ba5779c69e Fix queues as class members (#2525). 2020-08-29 12:56:43 -04:00
Wilson Snyder 069eb97eca SystemC 2.3.0 or newer (SYSTEMC_VERSION >= 20111121) is now required. 2020-08-29 10:45:47 -04:00
Wilson Snyder 96a959154a Commentary #2518. 2020-08-29 10:22:50 -04:00
Yutetsu TAKATSUKASA 4f88ec3518 Fix hier test failure on mac (#2524)
* No need to link the intermediate .so in hierarchical verilation

* apply clang-format

* run all tests in ci instead of cron. DONT_MERGE

* Add -undefined dynamic_lookup for mac environment when linking a shared protect-lib.

* Let's just check on mac for now. DONT_MERGE

* Revert "Let's just check on mac for now. DONT_MERGE"

This reverts commit 533fac6f9f.

* Revert "run all tests in ci instead of cron. DONT_MERGE"

This reverts commit fb4ac1fb42.
2020-08-29 07:56:06 -04:00
Patrick Stewart ef4f91ae5a CMake: Unconditionally require C++11 or greater (#2522) 2020-08-28 00:01:47 -04:00
Wilson Snyder 45eccaecaf Fix Travis/GCC warnings. 2020-08-27 18:48:26 -04:00
Wilson Snyder 0397e19726 Tests: CMAKE flags fix, #2514. 2020-08-27 18:48:10 -04:00
Wilson Snyder 687edba969 Make: less verbose archive 2020-08-27 18:47:12 -04:00
Wilson Snyder 02e83da2fa Fix Travis/GCC warnings. 2020-08-27 08:47:34 -04:00
Yutetsu TAKATSUKASA ef04ada12b Fix test failure on FreeBSD (#2521)
* Don't use thin-archive to merge multiple archives because it is gnu-ar specific.

* remove -time option that may caues -Wunused-command-line-argument warning
2020-08-27 07:52:48 +09:00
Wilson Snyder bed3101dfc Internals: Use VL_RESTORER class to save/restore vars. No functional change intended. 2020-08-24 21:13:28 -04:00
Wilson Snyder 4265f9499d Support dotted references in foreach in early parsing (for UVM) 2020-08-24 19:33:26 -04:00
Yutetsu TAKATSUKASA 6acd5847e7 Fix range check in V3SplitVar to be consistent with #2507 (#2511)
* test:Add more tests for checking split_var for unpacked array.

* Fix range calculation of SliceSel and change to UASSERT_OBJ because the range check is done in V3Width beforehand.
2020-08-24 19:11:20 -04:00
Wilson Snyder 16547077a1 Remove temporary file. 2020-08-24 18:56:52 -04:00
Wilson Snyder 3ad3944f2c Fix Travis/GCC warnings. For VPI/DPI still avoid C++11. 2020-08-24 18:49:36 -04:00
Wilson Snyder be8f1a25c6 Commentary (#2510) 2020-08-24 08:58:33 -04:00
Wilson Snyder f7f3d3fd43 Fix splitting eval functions with --output-split-cfuncs (#2368). 2020-08-23 22:21:40 -04:00
Wilson Snyder 4003e01283 Commentary 2020-08-23 20:58:23 -04:00
Wilson Snyder 917d3b0fb3 Support virtual class 2020-08-23 20:27:25 -04:00
Wilson Snyder 3d073c9534 Fix class extends to use virtual destruction 2020-08-23 20:00:39 -04:00
Wilson Snyder 20206b1e2e Support simple class extends. 2020-08-23 19:37:56 -04:00
Wilson Snyder fefe731105 Tests: Better virtual test 2020-08-23 11:50:42 -04:00
Wilson Snyder 1dce6b2500 Support $stable 2020-08-23 11:34:19 -04:00
Wilson Snyder d2fac4aa2f Internals: Add --debug-exit-uvm 2020-08-23 09:05:18 -04:00
Wilson Snyder 132cc1d068 Parser: Move timing control unsupported message 2020-08-23 08:56:35 -04:00
Wilson Snyder f4a72946eb Support $urandom, $urandom_range without stability. 2020-08-23 08:42:50 -04:00
Wilson Snyder e10156548d Fix GCC warnings 2020-08-23 07:19:20 -04:00
Wilson Snyder 4e6d2cfe38 Fix class constructor error on assignments to const. 2020-08-22 22:44:00 -04:00
Wilson Snyder 7f3a73e314 Fix naming of "id : begin" blocks. 2020-08-22 22:21:37 -04:00
Wilson Snyder 143050e034 Fix fwrite GCC warning 2020-08-22 21:34:41 -04:00
Wilson Snyder 8455ee7091 Optimize one-statement fork/join into begin 2020-08-22 20:04:02 -04:00
Wilson Snyder 9702d11657 Support class extern. 2020-08-22 19:46:21 -04:00
Wilson Snyder decbf79f39 Convert unnamed error to new PKGNODECL error. 2020-08-22 19:42:21 -04:00
Wilson Snyder 2d7d2c5992 Fix false DECLFILENAME on black-boxed modules (#2430). 2020-08-22 16:56:21 -04:00
Wilson Snyder 2abbd5c145 Convert unnamed error to new PKGNODECL error. 2020-08-22 16:37:49 -04:00
Wilson Snyder 583605b218 Parser: Move extern decl unsupported message 2020-08-22 16:24:29 -04:00
Wilson Snyder 67fab0b4fc Internals: Add missing package null test. No functional change intended. 2020-08-22 10:22:56 -04:00
Wilson Snyder 43213fcdc2 Fix GCC warnings 2020-08-22 07:44:22 -04:00
Yutetsu TAKATSUKASA f632ea500c Fix slice of unpacked array calculation (Issue #2506) (#2507)
Fixes Issue #2506 by shifting index as ArraySel does
2020-08-22 15:23:26 +09:00
Wilson Snyder dbb69412e5 Travis: Use make -k 2020-08-21 08:31:27 -04:00
Wilson Snyder d7bc0ff5e5 Fix GCC warnings 2020-08-21 08:30:12 -04:00
Wilson Snyder 14604a24d6 Fix GCC warnings 2020-08-20 08:12:06 -04:00
Wilson Snyder 816c5e0dc9 Fix GCC warnings 2020-08-19 08:20:06 -04:00
Rupert Swarbrick aa39d020d8 Fix build with Bison 3.7 and newer (#2505) 2020-08-18 12:12:52 -04:00
Wilson Snyder b67f1f0e94 Fix GCC warnings 2020-08-18 08:10:44 -04:00
Wilson Snyder f5546febe8 Fix OSX GCC register warning. 2020-08-18 08:02:50 -04:00
Wilson Snyder 27181d534e Commentary 2020-08-17 07:57:38 -04:00
Wilson Snyder 698e0fbbd1 configure: Try compiler flags to get to C++11 (#2502) 2020-08-17 07:40:07 -04:00
Wilson Snyder ea9b65fe6d Hardcode VM_C11 as always need C++11 now 2020-08-16 15:10:43 -04:00
Wilson Snyder 3c1ed075e5 tests: Disable wide line test as breaks user commits. 2020-08-16 14:57:16 -04:00
Wilson Snyder 6013b54f7b clang-tidy cleanups. No functional change intended. 2020-08-16 14:55:46 -04:00
Wilson Snyder d75a8624c1 C++11: constexpr replacing defines. No functional change intended. 2020-08-16 14:19:12 -04:00
Wilson Snyder ac04e85a1c C++11: More range for. No functional change intended. 2020-08-16 12:54:32 -04:00
Wilson Snyder 78aee6f4e7 C++11: Use sized enums (+4% performance). 2020-08-16 12:05:35 -04:00
Wilson Snyder ee9d6dd63f C++11: Favor auto, range for. No functional change intended. 2020-08-16 11:44:06 -04:00
Wilson Snyder 034737d2a8 C++11: Use member declaration initalizations (in nodes). No functional change intended. 2020-08-16 11:44:06 -04:00
Wilson Snyder 72d2cff0a1 C++11: Use member declaration initalizations. No functional change intended. 2020-08-16 11:44:06 -04:00
Wilson Snyder 033e7ac020 C++11: Use member declaration initalizations. No functional change intended. 2020-08-16 11:44:06 -04:00
Wilson Snyder 042d3eed23 C++11: Use override where possible. No functional change. 2020-08-16 11:44:05 -04:00
Wilson Snyder ea4031cbd3 C++11: Use delegating constructors. No functional change. 2020-08-16 11:44:05 -04:00
Wilson Snyder c0127599df C++11: Use nullptr. No functional change. 2020-08-16 11:44:05 -04:00
Wilson Snyder 7c54a451a9 C++11: Remove pre-c11 VL_OVERRIDE etc. No functional change. 2020-08-16 11:44:05 -04:00
Wilson Snyder 2118038cb9 Commentary 2020-08-15 14:22:50 -04:00
Wilson Snyder 9927e8b3ee clang-format uses C++11 style. No functional change. 2020-08-15 09:48:08 -04:00
Yutetsu TAKATSUKASA 953a442827 Support hierarchical verilation using protect lib (#2206) 2020-08-15 09:43:53 -04:00
Wilson Snyder f3b28c5c74 Remove configure --enable-prec11-final 2020-08-15 09:39:59 -04:00
Wilson Snyder 7a33fe2bf2 devel release 2020-08-15 09:20:50 -04:00
Wilson Snyder bdecf6c4e1 Version bump 2020-08-15 09:14:36 -04:00
Wilson Snyder 6fcf05e2b6 Commentary 2020-08-15 09:12:36 -04:00
Peter Monsson 4a5e4b04f3 Support $rose and $fell. (#2148) (#2501) 2020-08-14 07:37:10 -04:00
Edgar E. Iglesias 5d98035170 Fix sc names (#2500)
cint.mainInt(nodep) walks the tree and populates m_ctorVarsVec.
Reuse EmitCImp cint for the slow mainImp() emition steps to make sure
we emit constructor calls to setup SystemC sc_module names.
2020-08-13 08:23:02 -04:00
Wilson Snyder 20c906261b Fix casting non-self-determined subexpressions (#2493). 2020-08-09 20:59:06 -04:00
Wilson Snyder 74754d94c3 Codacy fix 2020-08-06 22:03:00 -04:00
Wilson Snyder 98cd925fda Fix non-32 bit conversion to float (#2495). 2020-08-06 21:56:43 -04:00
Wilson Snyder e029ba845e Travis: Trusty must use default CPAN 2020-08-06 17:50:49 -04:00
Julien Margetts e53a522662 Fix protect lib VCS warning (#2479) 2020-08-04 17:07:40 -04:00
Wilson Snyder 2bc813da4a Refactor and test VL_MULS_MAX_WORDS 2020-08-03 22:12:24 -04:00
James HanlonandJames Hanlon 555408b5d3 Fix V3Unknown from running with flat XML output (#2494)
* Prevent V3Unknown pass from being run

Co-authored-by: James Hanlon <[email protected]>
2020-08-03 11:44:47 -04:00
Wilson Snyder a07f2b3611 Travis: Force CPAN mirror to avoid false failures. 2020-08-02 08:47:27 -04:00
Yutetsu TAKATSUKASA c85589371a Fix protect-lib without sequential logic (#2492)
* add a test for protect-lib without sequential logic that cause the follwoing error.

%Error: obj_vlt/t_prot_lib_comb/secret/secret.sv:78:14: syntax error, unexpected ')'
   78 |     always @() begin
      |              ^

* protect-lib wrapper must contain sequential signal related statements
only if the protected design is a sequential logic.

Diff looks big, but actually just add "if (m_hasClk)" condition.

Signed-off-by: Yutetsu TAKATSUKASA <[email protected]>
2020-08-01 07:16:15 -04:00
Peter Monsson 1280070abb Support $stable (#2488) 2020-07-28 18:26:24 -04:00
Wilson Snyder a52f975bd7 Fix combining different-width parameters (#2484). 2020-07-26 17:54:23 -04:00
Wilson Snyder 0c70f0c786 clang-format 2020-07-26 17:50:31 -04:00
Wilson Snyder edf6a40f19 Fix VL_CONSTHI truncation (#2473) 2020-07-18 17:35:20 -04:00
Piotr Binkowski 58739a0a99 Internals: add isProgram to AstModule (#2470)
This allows to check which AstModules were created from `program` keyword
2020-07-16 07:31:16 -04:00
Wilson Snyder 1488f9130d Enable simple function localparams (#2461) 2020-07-15 19:31:19 -04:00
Josh Redford a18d8cbe86 Test for arrayed interfaces (#2469). 2020-07-15 17:58:59 -04:00
Wilson Snyder bfea4b7f99 Fix arrayed interfaces, broke in 4.038 (#2468). 2020-07-15 17:58:26 -04:00
Wilson Snyder 84b8307938 Ignore .nfs files 2020-07-15 07:50:32 -04:00
Wilson Snyder ce340658d6 Internals: revert (#2467) 2020-07-15 07:50:17 -04:00
Piotr Binkowski a02c420064 Internals: separate AST class for program (#2467) 2020-07-15 07:39:58 -04:00
Marshal Qiao d55c233427 Fix bad delete in verilated_save.h (#2462) 2020-07-14 06:39:00 -04:00
Marshal Qiao 25bbbbd37b Update Contributors (#2465) 2020-07-14 06:36:01 -04:00
Wilson Snyder fdb4d3a145 Fix coredump with UVM parse, caused by recent commit. 2020-07-11 20:32:27 -04:00
Wilson Snyder ced1af8cb8 Parser: Move extends param class unsupported message 2020-07-11 19:53:41 -04:00
Wilson Snyder f0a6e4c2b2 Parser: Move scoped id unsupported messages down out of parser 2020-07-11 19:11:58 -04:00
Wilson Snyder 9e5cd463e5 Parser: Move class parameter unsupported messages down out of parser 2020-07-11 18:39:01 -04:00
Wilson Snyder bb8899f307 Internals: Rename AstPackageRef as may point to class. 2020-07-11 10:29:15 -04:00
Wilson Snyder 1194dbf19c devel release 2020-07-11 09:18:40 -04:00
Wilson Snyder 0cd4a57ad9 Version bump 2020-07-11 09:05:24 -04:00
Wilson Snyder 1bd1e21a69 Change --enable-prec11 to --enable-prec11-final and give stronger warning 2020-07-11 08:56:40 -04:00
Wilson Snyder 7e7447812c Fix modulus exception (#2460) 2020-07-11 08:17:16 -04:00
Wilson Snyder af3ab13012 Tests: Fix 64-bit code coverage, part of last commit 2020-07-10 22:38:08 -04:00
Wilson Snyder b35b5aacfa Fix division exception (#2460) 2020-07-10 22:28:02 -04:00
Wilson Snyder 9c01665078 Tests: Fix bison stability. 2020-07-10 22:05:51 -04:00
Wilson Snyder a500140f1d Fix Bison 3.6 error messages 2020-07-10 21:54:58 -04:00
Wilson Snyder dced49a804 Internals: Cleanup branch coverage. No functional change. 2020-07-10 19:17:21 -04:00
Wilson Snyder f8a67b2fe8 Configure: Show bison/flex version. 2020-07-10 18:37:31 -04:00
Wilson Snyder 8cdecd5668 Commentary: Changes update 2020-07-10 18:18:02 -04:00
Wilson Snyder 75d255a3bf Internals: clang-format 2020-07-10 18:08:04 -04:00
Wilson Snyder 0674267333 Parser: Test and handle semaphore, mailbox and process. 2020-07-09 20:04:22 -04:00
Geza Lore 1632160fb1 Internals: Remove redunand SenItem nodes (#2457) 2020-07-05 13:13:03 -04:00
Geza Lore e609328ebb Ensure VarRef inherits dtype when varp is set.
Inlining used to set some VarRefs to point to new Var nodes, without
updating the dtype of the VarRef to the dtype of the new Var.
AstNode::sameTree does identity comparison on the dtype, so some trees
that were semantically the same did not compare as such with sameTree
because of the dtype. This in turn results in some missed opportunities
for combining equivalent SenTree sensitivities when the clock came from
outside.
2020-07-05 16:09:22 +01:00
Yutetsu TAKATSUKASA 8291ef6537 Internals: Pass FileLine to findDotted() for error location (#2455)
* Pass FileLine so that findDotted() will be able to tell the error location though it is not used yet.

* reorder the parameter order. No functional change is intended.
2020-07-04 09:35:04 -04:00
Yutetsu TAKATSUKASA 30600bf1a3 Internals: Add const 2020-07-03 14:16:43 -04:00
Wilson Snyder b968f57711 Suppress unsupported constraint, as implied by unsupported randomize. 2020-07-02 21:10:05 -04:00
Wilson Snyder ee7b399bf5 Parser: Move 'static' unsupported messages down out of parser. 2020-07-02 21:02:49 -04:00
Wilson Snyder 50c28fa9d3 Parser: Move 'pure virtual' and 'extern' unsupported messages down out of parser. 2020-07-02 08:24:50 -04:00
Geza Lore a17f51eac0 Improve V3MergeCond
- Do try to merge after assignment to condition when possible.
- Do not try to merge reduced form if not the expected statement.
  This used to cause a crash.
2020-07-02 13:13:51 +01:00
Yutetsu TAKATSUKASA cc50126ad3 Internals: Generalize V3Config to be able to set any module pragma. No functional change intended. (#2451) 2020-07-02 07:54:37 -04:00
Wilson Snyder 9d1a39a5e4 Parser: Move 'with' block unsupported messages down out of parser 2020-07-02 07:36:15 -04:00
Yutetsu TAKATSUKASA 82cc1a319f Internals: Simplify condition in V3Dead.cpp. No functional change intended. (#2454) 2020-07-02 07:35:55 -04:00
Yutetsu TAKATSUKASA 2fd23458ce Internals: Factor out making a make cmd string in Verilator.cpp. No functional change intended. (#2453) 2020-07-02 07:30:40 -04:00
Yutetsu TAKATSUKASA 271fa5fe3c Internals: move parseParamLiteral() to AstConst . No functional change intended. (#2452) 2020-07-02 07:29:52 -04:00
Fan Shupei 04c96694e6 Add $writememb support (#2450) 2020-07-01 17:32:15 -04:00
Wilson Snyder e7bd44561c Parse dotted new 2020-07-01 07:39:37 -04:00
Wilson Snyder 4d5e448664 Parser: Move member qualifier unsupporteds out of parser. 2020-07-01 07:31:53 -04:00
Wilson Snyder 236c2141e3 Parser: Move 'with' block unsupported messages down out of parser 2020-06-30 21:37:11 -04:00
Wilson Snyder 788fe3dc27 Tests: Ignore gtkwave spaces. 2020-06-30 21:36:39 -04:00
Wilson Snyder a2abd361db gtkwave: Update to match spacing of upstream. No functional change. 2020-06-30 19:16:10 -04:00
Geza Lore 09806d7576 Update fstapi.c to latest (fix undefined thread behaviour) 2020-06-30 19:50:41 +01:00
Geza Lore a2aa678278 Travis: only use SystemC when not M32 2020-06-30 19:16:28 +01:00
Wilson Snyder 0b09636c58 Support for-loop increments with commas. 2020-06-29 21:18:41 -04:00
Wilson Snyder af197f2ceb Parser: Move 'virtual class' block unsupported messages down out of parser 2020-06-29 21:03:14 -04:00
Wilson Snyder 748c818ccb Parser: Move 'wait' block unsupported messages down out of parser 2020-06-29 20:39:39 -04:00
Wilson Snyder ad55564905 Parser: Move disable fork and wait fork down into elaborate stage 2020-06-29 20:22:39 -04:00
Wilson Snyder ad2cb45a14 Parser: Move unsupported error detection of 'this'/'super' down into link stage 2020-06-29 20:02:15 -04:00
Wilson Snyder 277fd9197f Tests: Add number case for #2432. 2020-06-29 18:03:16 -04:00
Wilson Snyder 61ff7039b4 Commentary (#2439) 2020-06-28 18:37:42 -04:00
Geza Lore 7342cf278a Travis: Add 32-bit build on focal 2020-06-28 20:11:22 +01:00
Harald Heckmann 958654909f Added perl-doc to optional apt packages (#2445) 2020-06-28 11:00:57 -04:00
Geza Lore d9be86d69a Remove Travis FreeBSD debug acces workaround (ENV_HACK) 2020-06-28 15:37:24 +01:00
Geza Lore 378d947702 Travis: Add FreeBSD build + portability fixes 2020-06-28 15:37:24 +01:00
Stephen Henry 98b5417e04 Disable argument template type deduction. (#2426)
Fixes #2421, #2435 relating to 32-bit build failures.
2020-06-28 10:54:15 +01:00
Wilson Snyder 0af971292e Commentary (#2437) 2020-06-27 22:35:31 -04:00
Wilson Snyder 43a2fa080a For maintainers, set fill-column. 2020-06-27 21:44:32 -04:00
Geza Lore 0cdc2e038c Workaround for Travis OS X dbg exe corruption 2020-06-25 14:12:24 +01:00
Geza Lore d4a411db6c Don't use configure default compiler flags 2020-06-24 11:44:25 +01:00
Geza Lore 8d367dc8a3 Fix github links in documentation (#2443) 2020-06-24 11:09:49 +01:00
Geza Lore 5a4cc333fb Travis: Add OS X build (#2440) 2020-06-22 10:13:54 +01:00
Ludwig Rogiers f13fd4478c Init params in constructor to support pre-c++11 compilers 2020-06-22 09:01:39 +01:00
Geza Lore 23e4a0f784 Improve documentation 2020-06-20 05:17:46 +01:00
Geza Lore aa595d40de Do not fold IF with 'bx condition before V3Unknown (#2438)
Fixes #2425
2020-06-20 04:16:07 +01:00
Wilson Snyder fa828ac9ba Commentary (#2419) 2020-06-14 10:47:17 -04:00
Wilson Snyder b1495f0742 Commentary (#2423) 2020-06-14 10:44:57 -04:00
Stefan Wallentowitz 8006b5479c Missing entry in Changes for VPI parameters (#2417) 2020-06-13 05:22:12 -04:00
Yutetsu TAKATSUKASA 19c2906a64 Improve code coverage of V3SplitVar.cpp (#2418) 2020-06-13 04:45:47 -04:00
Ludwig Rogiers c367b671b6 Support VPI parameter and localparam (#2370) 2020-06-12 18:38:01 -04:00
Wilson Snyder 35226d5e1a Commentary 2020-06-12 08:12:54 -04:00
Geza Lore fac89c5d62 Close trace on vl_fatal/vl_finish (#2414)
This is required to get the last bit of FST trace and close the FST file
properly on $stop or assertion failure.
2020-06-12 07:15:42 +01:00
Conor McCullough f40f0464e2 Fix replaceMulShift optimization (#2413) 2020-06-11 07:42:25 -04:00
Wilson Snyder 262ed9c03a Tests: Avoid using std. No functional change. 2020-06-10 08:04:34 -04:00
Yutetsu TAKATSUKASA a7edf13d62 Fix V3SplitVar test stability (#2408) 2020-06-09 22:39:10 -04:00
Wilson Snyder 6e57076726 Support --bbox-unsup parsing of nested foreach. 2020-06-09 22:05:06 -04:00
Wilson Snyder cef56c6fca Support --bbox-unsup parsing of class extend typedefs 2020-06-09 20:59:45 -04:00
Wilson Snyder 91f30af01f Fix --bbox-unsup crash from earlier commit. 2020-06-09 19:49:11 -04:00
Wilson Snyder 3c8953fec2 Fix $sformat with non-constant string first argument 2020-06-09 19:40:49 -04:00
Wilson Snyder 6de78d58fa Add new UNSUPPORTED error code to replace most previous Unsupported: messages. 2020-06-09 19:20:16 -04:00
Wilson Snyder d42f9c095b Delay parsing of associative arrays until dtypes known. 2020-06-09 07:13:40 -04:00
Wilson Snyder 46e10173f8 Support --bbox-unsup parsing of class extern function/task. 2020-06-08 22:33:57 -04:00
Wilson Snyder d84c7df38f Internals: Reformat V3Options. No functional change. 2020-06-08 22:17:30 -04:00
Wilson Snyder 6e2d8df9e5 Tests: Add --debug-exit-parse 2020-06-08 22:10:55 -04:00
Wilson Snyder e2b40195b4 Tests: Reference issue #2410. 2020-06-08 20:58:04 -04:00
Wilson Snyder 541f983dba Merge tests from issue-2409-timing (but disabled mostly) 2020-06-08 20:36:22 -04:00
Wilson Snyder 5658cd3394 Commentary 2020-06-08 20:11:29 -04:00
Wilson Snyder 3963a50aef Internals: Refactor param array handling to use subroutine. No functional change intended. 2020-06-08 07:43:07 -04:00
Wilson Snyder 47f040a5fd Internals: Do data type elaboration always as child node, before movement to symbol table. 2020-06-08 06:47:18 -04:00
Wilson Snyder 7b7a2e99e3 Internals: Misc parser cleanups. 2020-06-07 22:15:19 -04:00
Wilson Snyder 25397e7612 Author site: Don't rebuild revision if VERILATOR_NO_OPT_BUILD 2020-06-07 20:08:19 -04:00
Wilson Snyder 4984d19ae9 Support --bbox-unsup parsing :: referencing typedef in class 2020-06-07 19:59:03 -04:00
Wilson Snyder 305448ea86 Cleanup parser errors to identify packages by :: instead of symbol table 2020-06-07 16:54:25 -04:00
Wilson Snyder 4a1d18f0e9 Internals: Refactor parser pipeline to use deque. No functional change intended. 2020-06-07 15:35:36 -04:00
Wilson Snyder 30482f3eea Internals: Add parser debug printer. 2020-06-07 14:07:15 -04:00
Wilson Snyder b469feb44b Fix some syntax error context by splitting internal parse and lex filelines 2020-06-07 13:45:50 -04:00
Wilson Snyder 466fd56d18 Move XML verilator tag handling into parser. 2020-06-07 13:09:18 -04:00
Wilson Snyder 1aaf3f3424 Internals: Rename parser functions called by lexer. No functional change intended. 2020-06-07 12:18:23 -04:00
Wilson Snyder b5e4917405 Internals: Pass unconnected drive in parser token stream. 2020-06-07 12:08:12 -04:00
Wilson Snyder 140671300c Internals: Pass parser celldefine state through FileLine. No functional change intended. 2020-06-07 11:58:53 -04:00
Wilson Snyder 820a4dbbdd Internals: Pass fileline directly. No functional change intended. 2020-06-07 10:53:21 -04:00
Wilson Snyder 53d8ccd149 Internals: Move yyerror to parser. No functional change intended. 2020-06-07 10:31:42 -04:00
Wilson Snyder 418b36ea71 Internals: Pass fileline directly and avoid yyerror 2020-06-07 10:17:50 -04:00
Wilson Snyder 05e51d0d18 Tests: Excempt some wide files 2020-06-07 09:59:09 -04:00
Wilson Snyder 575c565e77 Internals: Refactor to decouple LinkDot from ParseImp. No functional change intended. 2020-06-07 08:23:01 -04:00
Wilson Snyder 01255082a6 Internals: Refactor to decouple LinkDot from ParseImp. No functional change intended. 2020-06-07 08:21:22 -04:00
Wilson Snyder 0098e67e59 Tests: Use lint in many negative tests to avoid running under both vlt and vltmt 2020-06-07 07:15:07 -04:00
Wilson Snyder 3798a472b5 Commentary: Indicate mid-rule parser actions. 2020-06-06 17:42:10 -04:00
Wilson Snyder 0e322e2e85 Fix segfault after pin unsupported error. 2020-06-06 16:17:41 -04:00
Wilson Snyder 5cd5c05c05 Support --bbox-unsup parsing of event control expressions 2020-06-06 15:54:44 -04:00
Wilson Snyder 933e796cc2 Support $swrite with arbitrary arguments 2020-06-06 14:47:54 -04:00
Wilson Snyder ae701e014d Support --bbox-unsup parsing of for with multiple increments 2020-06-06 13:55:15 -04:00
Wilson Snyder 3a0b8c8870 Fix parsing parameter type with assignment and no type keyword. 2020-06-06 13:44:45 -04:00
Geza Lore dea0e6793f Simplify V3SenTree.h. No functional change intended.
- Remove unused headers
- Simplify container functors
- SenTreeFinder need not be a Visitor
- Update comments

Line coverage should now be 100%
2020-06-06 17:30:32 +01:00
Wilson Snyder 4862916f39 Support --bbox-unsup parsing of 'constraint', 'dist', 'solve' 2020-06-06 12:08:36 -04:00
Wilson Snyder 870ec27b73 Support --bbox-unsup parsing of 'randomize' 2020-06-06 11:22:48 -04:00
Wilson Snyder a21947d887 Support --bbox-unsup parsing of 'with' 2020-06-06 11:11:23 -04:00
Wilson Snyder 893dee3434 Support --bbox-unsup parsing of forward defed class calls 2020-06-06 10:21:16 -04:00
Wilson Snyder f083805ab5 Support --bbox-unsup parsing of parameterized classes 2020-06-06 10:06:32 -04:00
Wilson Snyder 7067afde5d Support --bbox-unsup parsing of foreach(this.foo) 2020-06-06 09:43:13 -04:00
Wilson Snyder 1eaec2aa8a Support --bbox-unsup of $cast 2020-06-06 09:30:11 -04:00
Wilson Snyder da01810d98 Internals: Add UNSUP tokens from VParseBison and sort lists. No functional change. 2020-06-06 09:09:26 -04:00
Wilson Snyder 4c7d5a1dc0 Fix --bbox-unsup to bypass more parser unsupported errors. 2020-06-06 08:50:47 -04:00
Wilson Snyder d15e3d93c4 Internals: Reindent and move parser code. No functional change. 2020-06-06 08:44:44 -04:00
Wilson Snyder aae2bf872c devel release 2020-06-06 07:51:54 -04:00
Wilson Snyder 04c0fc8aa7 Version bump 2020-06-06 07:48:47 -04:00
Wilson Snyder 1d8955fea5 Internal: Update fastcov.py from upstream. 2020-06-06 05:48:36 -04:00
Wilson Snyder 48740a0dba Tests: Add t_param_type 2020-06-05 22:22:44 -04:00
Geza Lore 4a404bd92e Always mask LSB in V3Merge Cond when mergin AstAnd 2020-06-06 00:17:59 +01:00
Wilson Snyder ff41701ddc Fix crash on undeclared packages. 2020-06-05 18:50:06 -04:00
Wilson Snyder 2590c9c4a6 Internal: Update fastcov.py from upstream. 2020-06-05 18:05:49 -04:00
Wilson Snyder c5d61da5d2 Internal coverage: Fix coverage of tests that abort. No functional change intended. 2020-06-05 08:00:22 -04:00
Wilson Snyder 5a622fd9db Tests: Temporary fix for (#2407) 2020-06-05 07:28:51 -04:00
Wilson Snyder c83b1478e1 Internals: Ifdef out V3Combine incomplete dead code. 2020-06-04 21:55:00 -04:00
Wilson Snyder 3243651c63 Internals: Fix misc internal coverage holes. No functional change intended. 2020-06-04 21:40:40 -04:00
Wilson Snyder 8d61cd9029 New fastcov internal coverage scheme 2020-06-04 20:59:52 -04:00
Wilson Snyder 7fe49de420 Tests: Tests to fix misc internal coverage holes. 2020-06-04 20:23:55 -04:00
Wilson Snyder a433096d5a Internals: Fix misc internal coverage holes. No functional change intended. 2020-06-04 19:49:39 -04:00
Geza Lore b88e1e6970 Travis: Fix cron (always build focal) 2020-06-04 17:36:53 +01:00
Wilson Snyder 79f228b04f Remove dead code (bisonreader) 2020-06-03 20:11:09 -04:00
Wilson Snyder d7cc1e6844 Tests: Use lint in many negative tests to avoid running under both vlt and vltmt 2020-06-03 20:05:13 -04:00
Wilson Snyder 42312101b5 Tests: Add array OOB tests as unsupported (#792) 2020-06-03 19:36:50 -04:00
Wilson Snyder 329f5b712a Tests: Add alias tests as unsupported (#697) 2020-06-03 19:27:22 -04:00
Geza Lore 6ddd92c0a1 Travis: Use workspaces and per job persistent ccache (#2399)
Change the Travis builds to use workspaces and persistent ccache

We proceed in 2 stages (as before, but using workspaces for
persistence):
1. In the 'build' stage, we clone the repo, build it and
   save the whole checkout ($TRAVIS_BUILD_DIR) as a workspace
2. In the 'test' stage, rather than cloning the repo, multiple jobs
   pull down the same workspace we built to run the tests from

This enables:
- Reuse of the build in multiple test jobs (this is what we used the Travis
  cache for before)
- Each job having a separate persistent Travis cache, which now only
  contains the ccache. This means all jobs, including 'build' and 'test'
  jobs can make maximum use of ccache across runs. This drastically cuts
  down build times when the ccache hits, which is very often the case for
  'test' jobs. Also, the separate caches only store the objects build by
  the particular job that owns the cache, so we can keep the per job
  ccache small.

If the commit message contains '[travis ccache clear]', the ccache will
be cleared at the beginning of the build. This can be used to test build
complete within the 50 minute timeout imposed by Travis, even without a
persistent ccache.
2020-06-03 21:10:13 +01:00
Tomasz Gorochowik 277dee109c Fix Ariane issues with PostAdd nodes (#2400) 2020-06-03 12:50:24 -04:00
Wilson Snyder ef71576825 Fix coredump from increment patch (#2391) 2020-06-03 08:30:49 -04:00
Wilson Snyder c3271aa891 Fix duplicate VLCOVGEN short code 2020-06-02 21:42:24 -04:00
Geza Lore 1cf17b5e78 Fix unused variable. 2020-06-02 22:45:55 +01:00
Ludwig Rogiers 2b6353b36e Support vpi_handle type vpiLeftRange and vpiRightRange for vpiRange objects (#2395)
* Implement vpi_handle type vpiLeftRange and vpiRightRange for vpiRange objects

* Change VerilatedVpioConst type to vpiConstant
2020-06-02 08:04:22 -04:00
Wilson Snyder 8b647f0977 Fix error on UNPACKED in parser. (#1541) 2020-06-02 08:00:37 -04:00
Wilson Snyder 4c31c5fab5 Fix unused variable. 2020-06-02 07:52:27 -04:00
Wilson Snyder 6ce878cb0d Fix some clang-tidy warnings 2020-06-01 23:16:17 -04:00
Geza Lore a67ba04c37 Remove dead code and some unused parameters
Found with CLion inspections
2020-06-01 17:49:42 +01:00
Wilson Snyder ae448e5ef9 Fix older GCC compiler error. 2020-06-01 09:08:50 -04:00
Wilson Snyder a57826b125 Line Coverage now tracks all statement lines, not just branch lines. 2020-05-31 15:52:17 -04:00
Geza Lore 656c460605 Add --dump-tree-addrids developer option 2020-05-31 20:21:55 +01:00
Geza Lore 95534fa5c5 Remove unused headers (#2389) 2020-05-31 20:21:07 +01:00
Wilson Snyder 611e8b10c6 Fix Verilog coverage to pass real column information 2020-05-31 09:05:10 -04:00
Michael Killough 047852eb08 Fix OpenBSD make in tests. (#2388) 2020-05-31 09:03:51 -04:00
Geza Lore 6318a08056 Fix --dump-tree with sparse dumps.
"No changes since last dump!" is now only printed if the "last" dump was
actually performed and not skipped due to V3Option::dumpTreeLevel
settings.
2020-05-31 13:48:30 +01:00
Wilson Snyder b60a92eed3 Fix pre-C11 compiler warning. 2020-05-30 21:11:37 -04:00
Geza Lore fe306a36b8 Add MergeCond pass to combine assignments with ?: on rhs (#2376)
This provides minor simulation performance benefit, but can provide
large C++ compilation time improvement, notably with Clang (4x).

This patch implements #2366 .
2020-05-30 21:09:05 +01:00
Geza Lore 18870f8b62 Remove remnants of long removed --trace-dups option
See #2385
2020-05-30 20:16:40 +01:00
Geza Lore 9712ceedd7 Internals: Remove empty statements. No functional change intended.
Remove stray semicolons, mostly by capturing them in macros accurately.
This removes a ton on lint warnings from CLion.
2020-05-30 19:13:18 +01:00
Wilson Snyder 2e32387e5c Fix GCC false warning on array bounds. (#2386) 2020-05-30 13:47:53 -04:00
Wilson Snyder b66877c9df Internals: Refactor V3Expand newWordSel. No functional change intended. 2020-05-30 13:47:53 -04:00
Geza Lore 74a6f94e2b Internals: Remove dead code 2020-05-30 17:20:23 +01:00
Wilson Snyder 35fc8b7259 Debug: Show column numbers in .tree files 2020-05-30 10:08:30 -04:00
Wilson Snyder e591afd101 Disable over-sensitive debug dump. 2020-05-30 09:35:48 -04:00
Wilson Snyder a41cdf4cfb Tests: Add driver_verilator_flags (for verilator_ext_tests) 2020-05-30 08:19:44 -04:00
Wilson Snyder ef72c42aa7 Commentary 2020-05-29 19:58:59 -04:00
Wilson Snyder fbc814b54a Internal code coverage fixes 2020-05-29 19:35:54 -04:00
Wilson Snyder 4cfa3f879a Internals: Allow VL_DANGLING on pointer const. 2020-05-29 18:31:53 -04:00
Wilson Snyder 4a8c7e869f Fix coverage issue 2020-05-29 17:59:35 -04:00
Tomasz Gorochowik a4a1c7a384 Fix swerv issues with Increment nodes (#2380) 2020-05-29 13:03:04 -04:00
Ludwig Rogiers 460315128b Fix vpi_get_value() error message when passing unsupported vpiHandle. (#2378) 2020-05-29 08:10:22 -04:00
Wilson Snyder 8ddafb4d9f Update contributors (from email) 2020-05-28 21:35:38 -04:00
Wilson Snyder ebda8f866c Cleanup codacity and missing consts. 2020-05-28 21:04:36 -04:00
Wilson Snyder 5ee4595aa8 Remove dead code (git_untabify), instead use make clang-format 2020-05-28 21:04:17 -04:00
Wilson Snyder 5089ac6119 Remove VL_ULL as ULL now in MSVC & C++11 2020-05-28 20:32:07 -04:00
Wilson Snyder 3f66f846cd Travis enable SystemC test (#1601) 2020-05-28 18:52:03 -04:00
Wilson Snyder 279f21bb5b Configure now enables SystemC if it is installed as a system headers. 2020-05-28 18:51:46 -04:00
Wilson Snyder 773ed97504 Internals Most VerilatedLockGuard can be const. No functional change intended. 2020-05-28 18:23:46 -04:00
Wilson Snyder b6d4899d3f Commentary 2020-05-28 18:09:31 -04:00
Maciej Sobkowski 9d48ff7745 Support pre/postifx incrementation/decrementation in array index (#2223) 2020-05-28 18:08:15 -04:00
Stephen Henry c4aab57c62 Internals: Refactor to introduce VerilatedFdList. (#2363) 2020-05-28 17:59:18 -04:00
Maarten De Braekeleer e8f27be200 Fix Visual Studio compiler issues (#2375)
* Make sure compiler creates same object file as target of rule
* MSVC requires a string return
* Case ranges are a gnu extension which MSVC does not understand
* _dupenv_s also returns 0 if the var could not be found
See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/dupenv-s-wdupenv-s?view=vs-2019
2020-05-28 17:39:20 -04:00
Wilson Snyder 15f0f967b3 Fix uninit variable warning 2020-05-28 17:33:44 -04:00
Wilson Snyder cbafff8a71 Commentary 2020-05-27 21:52:55 -04:00
Wilson Snyder 41e362b580 Tests: Remove some old conditional-fail checks. 2020-05-27 21:44:28 -04:00
Geza Lore 622f59ad65 Set OPT_FAST=-Os as default (#2374) 2020-05-28 00:57:49 +01:00
Wilson Snyder c5da38206e Fix configure over-disabling warnings. 2020-05-27 08:45:11 -04:00
Geza Lore d737266f64 Add OPT_GLOBAL to use for run-time library (#2373)
This allows compiling the run-time library with optimization even when OPT_FAST is not used in order to imporove model build speed, possibly during debug cycles.
2020-05-27 01:52:08 +01:00
Wilson Snyder 978c35995a Support const cast (ignored since not linting const yet) 2020-05-26 20:44:20 -04:00
Wilson Snyder 2af7f2fa18 Internals: Parser cleanup of cast. 2020-05-26 20:29:54 -04:00
Wilson Snyder 373c9090d3 Update contributors (from email) 2020-05-26 19:12:19 -04:00
Stefan Wallentowitz 723d407a87 [docker] Unify docker files (#2371)
Unify the actions in the Dockerfiles between the runtime environment
and the run containers.

Fixes #2345

Signed-off-by: Stefan Wallentowitz <[email protected]>
2020-05-26 20:38:43 +02:00
Stefan Wallentowitz dc90e6c3c3 Generate file with waivers (#2354)
This adds the flag --generate-waivefile <filename>. This will generate
a verilator config file with the proper lint_off statemens to turn off
warnings emitted during this particular run.

This feature can be used to start with using Verilator as linter and
systematically capture all known lint warning for further
elimination. It hopefully helps people turning of -Wno-fatal or
-Wno-lint and gradually improve their code base.

Signed-off-by: Stefan Wallentowitz <[email protected]>
2020-05-26 20:38:14 +02:00
Stefan Wallentowitz 68a2ed6776 Fix output of loops on waiving (#2355)
When an unopt loop is waived, we also don't want the loop's example
path being plot.

Signed-off-by: Stefan Wallentowitz <[email protected]>
2020-05-26 08:45:57 +02:00
Wilson Snyder 7f32d4dc45 Internals: Parser cleanup of expressions. 2020-05-25 21:51:05 -04:00
Geza Lore 7b683fe258 Use sane --output-split values by default to help large builds
--output-split is now on by default with value 20000.
--output-split-cfuncs and --output-split-ctrace now defaults to the
value of --output-split unless explicitly specified.
2020-05-26 01:22:10 +01:00
Geza Lore 72858175a2 Only emit VM_PARALLEL_BUILDS=1 iff --output-split caused a split.
Previously we set VM_PARALLEL_BUILDS=1 if the --output-split option was
provided. Now we only do it iff it actually causes a split.
2020-05-26 01:22:10 +01:00
Geza Lore 9d7086067c Rework serial/parallel build mode
Instead of __ALLfast.cpp and __ALLslow.cpp, we now create only a single
__ALL.cpp and compile it with OPT_FAST, this speeds up small builds
where the C compiler does not dominate. A separate patch will follow
turning VM_PARALLEL_BUILDS on by default at a certain size.

Given this change to the build there is now no point in emitting both
fast and slow routines into the same .cpp file when --output-split is
not set as they will be just included in the same __ALL.cpp file. To
keep things simpler and the output easier to comprehend, V3EmitC has
also been changed to always emit the fast and slow files separately.

Also change verilated.mk to apply OPT_SLOW to all slow files, not just
ones called *__Slow.cpp. This change in particular ensures __Syms.cpp
is build as slow.

Part of #2360.
2020-05-26 01:22:10 +01:00
Wilson Snyder 5bb1da88ed Internals: Comment grammar continuations. No functional change. 2020-05-25 19:40:20 -04:00
Wilson Snyder 9969a60b34 Commentary 2020-05-25 18:51:12 -04:00
Wilson Snyder 72402fa91e Internals: Parser cleanup of parameters, second part. 2020-05-25 18:49:29 -04:00
Wilson Snyder 8255f3f9fe Internals: Parser cleanup of parameters, first part. 2020-05-25 18:41:47 -04:00
Wilson Snyder 8957f77793 Internals: Refector needHeavy into methods. No functional change intended. 2020-05-25 15:34:24 -04:00
Wilson Snyder 7187b82d1d Update contributors (from email). 2020-05-25 13:36:24 -04:00
Ahmed El-Mahmoudy 1a92a58720 Fix spelling mistakes (#2364) 2020-05-25 12:43:32 -04:00
Wilson Snyder 2351f9b9ad Update contributors (from email). 2020-05-25 10:54:22 -04:00
Wilson Snyder abc3c216f8 Internal code coverage: Better support fastcov [still not default]. 2020-05-25 10:50:46 -04:00
Wilson Snyder f1afa667d7 Update contributors. 2020-05-25 09:16:40 -04:00
Wilson Snyder 76d0671952 Travis: Fix cron. 2020-05-25 08:46:46 -04:00
Jan Van Winkel 424769c32b Fix warning for unused param in VL_RTOIROUND_Q_D (#2356) 2020-05-25 08:13:12 -04:00
Wilson Snyder f7249ad23a Internals: AstRefDType points to AstTypedef instead of sub-dtype, in prep for future commits. 2020-05-24 14:22:06 -04:00
Wilson Snyder 613d76c578 Travis: Fix cron. 2020-05-24 08:30:59 -04:00
Wilson Snyder 50662751fe Fix compiler unsigned warnings 2020-05-23 22:38:17 -04:00
Wilson Snyder c9e59e767a Tests: Add setenv method. 2020-05-23 22:24:26 -04:00
Vassilis Papaefstathiou a7432bdea7 Support wide operands in queues and dynamic arrays (#2352) 2020-05-23 21:59:56 -04:00
Wilson Snyder 9ffad7f0db Internal cleanups. No functional change intended 2020-05-23 21:57:08 -04:00
Wilson Snyder 3097d5e093 Commentary 2020-05-23 21:56:56 -04:00
Yuri Victorovich cff4b5a5ee Fix WIFEXITED error on FreeBSD. (#2351) (#2353) 2020-05-23 16:30:36 -04:00
Wilson Snyder eda46e3949 Internals: Favor exprOrDataType where possible. No functional change intended. 2020-05-23 13:08:56 -04:00
Wilson Snyder 71651718d4 Internals: Track :: in AstDot parsing. No parsing change intended. 2020-05-23 12:44:15 -04:00
Wilson Snyder da0cb44954 Internals: Refactor parsing id's up to parent rules. No functional change intended. 2020-05-23 12:19:43 -04:00
Wilson Snyder 57621a93ad Internals: Move PLI errors into linker, and better test. 2020-05-23 11:55:34 -04:00
Wilson Snyder 6a882f9dc6 Internal code coverage improvements. No functional change intended. 2020-05-23 10:34:58 -04:00
Wilson Snyder c18b0eb122 Internal coverage: Limit parallelism to core count. 2020-05-23 09:50:04 -04:00
Wilson Snyder 3c28a66acf Internal coverage: Fix --hashset option. --stop now default. 2020-05-23 09:17:16 -04:00
Wilson Snyder 5c11de1663 Tests: Check queue typedef. 2020-05-22 22:14:26 -04:00
Wilson Snyder 72ea6bf414 Travis: Fix cron. 2020-05-22 08:39:56 -04:00
Ludwig Rogiers 101314a572 Add VPI error reset to vpi_get_time() (#2347) 2020-05-22 07:09:47 -04:00
Wilson Snyder 01f3e81a36 Internals: Parse extend/implements/etc using generic identifiers. 2020-05-21 21:31:15 -04:00
Wilson Snyder 3cb3b6c400 clang-format verilog.l. No functional change. 2020-05-21 19:46:21 -04:00
Wilson Snyder 8f58b58853 Internals: Parse using idAny where can to better detect id errors. 2020-05-20 23:29:37 -04:00
Wilson Snyder b66826169d Internals: Refactor inherits/extends parse so don't need type vs nontype IDs. 2020-05-20 23:10:45 -04:00
Wilson Snyder d2a7376f14 Fix spacing. No functional change 2020-05-20 22:33:32 -04:00
Wilson Snyder c9e8a1cb4d Commentary 2020-05-20 20:31:57 -04:00
Wilson Snyder 8170f6f03f Travis: Fix cron. 2020-05-20 17:39:32 -04:00
Stefan Wallentowitz 0abf88823f Docker upgrade to Ubuntu 20.04 (#2318)
* [docker] Remove versions from Docker files

There is no dependency on an actual version, it was only there to
silence the linter. Instead the linter is now set to not warn about
it.

Signed-off-by: Stefan Wallentowitz <[email protected]>

* [docker] Update to Ubuntu 20.04

Update to new Ubuntu release:

 - Only GCC 9.3 available. Also add clang (10.0) now.
 - SystemC is now a package 🎉

Signed-off-by: Stefan Wallentowitz <[email protected]>
2020-05-20 06:58:43 -04:00
Todd Strader accf5a9a17 Check if Parallel::Forker is new enough (#2343) 2020-05-19 14:31:13 -04:00
Wilson Snyder c64c81b7a3 Workaround missing guard (partial #2333). 2020-05-19 08:31:52 -04:00
Wilson Snyder 7834028842 Tests: Skip genhtml if too old 2020-05-19 08:24:21 -04:00
Wilson Snyder 1e0d5eb238 Release examples/Makefiles under CC0. 2020-05-18 22:23:19 -04:00
Wilson Snyder b5460bd867 Travis-CI fixes 2020-05-18 18:34:26 -04:00
Geza Lore 53cde90c8f De-constify fields to appease old GCC with broken STL
No functional change intended, fixes #2342
2020-05-18 19:01:08 +01:00
Geza Lore d20a4db773 Fix regression due to early constant folding in +: and -: (#2338) 2020-05-18 18:46:00 +01:00
Wilson Snyder 0f7677480f Commentary 2020-05-18 08:11:56 -04:00
Stephen Henry ba3930777a Support display/scan %u/%z (#2324) (#2332) 2020-05-18 08:10:32 -04:00
Geza Lore 9c054a5774 Optimize trace activity flags a bit more
- Improve flag pruning heuristic
- Set all trace activity flags in slow code. This in turns enables us
to remove checking the slow flag on the fast path.
2020-05-17 19:41:24 +01:00
Stephen Henry cef0105dfc Fix requiring C++11 algorithms. (#2339) (#2340) 2020-05-17 11:44:42 -04:00
Wilson Snyder 4773a1e77c Misc internal coverage improvements. 2020-05-17 11:06:14 -04:00
Wilson Snyder ed4c7038b4 Tracing: Remove dead code. No functional change intended. 2020-05-17 09:53:58 -04:00
Wilson Snyder c4f31d3bb6 Tracing: Remove dead code. No functional change intended. 2020-05-17 09:52:03 -04:00
Geza Lore dc25e9b949 Optimize fine grained trace activity flags (#2336)
Firstly, we always use a byte array for fine grained activity flags
instead of a bit vector (we used to use a byte array only if we had
parallel mtasks). The byte vector can be set more cheaply in eval,
closing about 1/3 of the gap in performance between compiling with
or without --trace on SweRV EH1. The speed of tracing itself is not
measurably different.

Secondly, we prune the activity tracking such that if a set of activity
flag combinations only guard a small number of signals, we will turn
those signals into awayls traced signals. This avoids code which
sometimes tests dozens of activity flags just to subsequently check one
signal and dump it if it's value changed. We can just check the signal
state straight instead, and not bother with the flags. This removes
about 30% of activity flags in SweRV EH1, and makes both single threaded
VCD and FST tracing 8-9% faster.
2020-05-17 13:53:02 +01:00
Wilson Snyder 1f52b01b2c Travis: Fix cron. 2020-05-17 08:48:31 -04:00
Wilson Snyder d5fc0fca41 Travis: Fix cron. 2020-05-17 08:19:42 -04:00
Wilson Snyder 212aa332dd Commentary 2020-05-16 18:53:18 -04:00
Wilson Snyder 17e7da77f0 Misc internal coverage improvements. 2020-05-16 18:02:54 -04:00
Wilson Snyder 201f0d3f5f Codecov badge 2020-05-16 15:02:22 -04:00
Wilson Snyder 7d0b3b300a Travis: Setup cron coverage 2020-05-16 14:59:30 -04:00
Wilson Snyder 0b55e205f7 Internal code_coverage: speedup aggregation. 2020-05-16 14:53:22 -04:00
Wilson Snyder 9c0c6439cc Clean additional objects. 2020-05-16 13:28:03 -04:00
Wilson Snyder d33d0301f8 Support verilator_coverage --write-info for lcov HTML reports. 2020-05-16 09:18:35 -04:00
Wilson Snyder 6fd7f45cef Internals: Remove dead needHInlines code 2020-05-16 07:53:27 -04:00
Wilson Snyder 57a937df03 Misc internal coverage cleanups 2020-05-16 07:43:22 -04:00
Wilson Snyder ffd461dcf8 Tests: Check need -cc message 2020-05-16 07:10:44 -04:00
Wilson Snyder f77058774e Add codecov.yml 2020-05-16 06:15:45 -04:00
Wilson Snyder 1d0a726437 Update internal code coverage framework. 2020-05-16 06:15:25 -04:00
Wilson Snyder 29bcbb0417 Suppress impossible code coverage issues 2020-05-15 22:34:29 -04:00
Wilson Snyder 2d11c2cbb3 Tests: Fix driver called with no tests 2020-05-15 22:33:35 -04:00
Wilson Snyder 2edbcce032 Tests: Need only one run of t_trace_c_api.pl 2020-05-15 22:33:20 -04:00
Wilson Snyder 35a53d9adb Add t_trace_c_api test. 2020-05-15 20:38:08 -04:00
Wilson Snyder 2885c2ce97 Fix coredump on countbits. 2020-05-15 19:29:17 -04:00
Geza Lore 900c023bb5 Refactor trace implementation to allow experimentation
The main goal of this patch is to enable splitting the full and
incremental tracing functions into multiple functions, which can then be
run in parallel at a later stage. It also simplifies further
experimentation as all of the interesting trace code construction now
happens in V3Trace. No functional change is intended by this patch, but
there are some implementation changes in the generated code.

Highlights:
- Pass symbol table directly to trace callbacks for simplicity.
- A new traceRegister function is generated which adds each trace
function as an individual callback, which means we can have multiple
callbacks for each trace function type.
- A new traceCleanup function is generated which clears the activity
flags, as the trace callbacks might be implemented as multiple functions.
- Re-worked sub-function handling so there is no separate sub-function
for each trace activity class. Sub-functions are generate when required
by splitting.
- traceFull/traceChg are now created in V3Trace rather than V3TraceDecl,
this requires carrying the trace value tree in TraceDecl until it
reaches V3Trace where the TraceInc nodes are created (previously a
TraceInc was also created in V3TraceDecl which carries the value).
2020-05-15 18:34:29 +01:00
Geza Lore 12b95f6b93 Clean up V3TraceDecl & V3Trace. No functional change intended.
- Constify variables
- Remove redundancies
- [Hopefully] make some code a bit more readable
2020-05-15 18:34:29 +01:00
Wilson Snyder 85de3048a5 Tests: Avoid poluting non-obj_ files. 2020-05-14 18:50:49 -04:00
Wilson Snyder c1a9fe07e9 Support multi channel descriptor I/O (#2190)
clang-format and Changes update. No functional change.
2020-05-14 18:14:50 -04:00
Stephen Henry 1a0da2e4ec Support multi-channel descriptor (MCD) I/O (#2197) 2020-05-14 18:03:00 -04:00
Wilson Snyder 38d11ecabe Commentary 2020-05-13 21:06:00 -04:00
Wilson Snyder 148762364b Tests: Complicated for loops long ago supported. 2020-05-13 20:53:55 -04:00
Huang Rui 68d7596adf Fix compile error when using bison 3.6.1 (#2320)
Workaround issue: bison 3.6.1 generated unexpected nested-comment
Closes: https://github.com/verilator/verilator/issues/2320
Signed-off-by: Huang Rui <[email protected]>
2020-05-13 19:18:56 -04:00
Wilson Snyder f005b7fd87 Support scan %* format 2020-05-11 22:13:59 -04:00
Wilson Snyder 68ed683681 Travis: Run 20.04 for non-cron, more others for cron. 2020-05-11 20:31:37 -04:00
Wilson Snyder 61e41595a2 Fix clang warning 2020-05-11 20:31:37 -04:00
Stephen Henry 484b574cef Fix crash on self-referential enum type. (#2319) 2020-05-11 18:44:28 -04:00
Wilson Snyder 29695adf70 Fix 10s/100s timeunits. 2020-05-11 08:15:52 -04:00
Wilson Snyder fac43811fd Commentary 2020-05-10 21:26:09 -04:00
Wilson Snyder 15f63d12d5 Fix message for seeded random. 2020-05-10 21:15:48 -04:00
Wilson Snyder ba7b3fd60f Support $display(,,). 2020-05-10 20:48:18 -04:00
Wilson Snyder 897b9ccfe2 Fix display of huge double. 2020-05-10 16:03:46 -04:00
Wilson Snyder b97e1aa9fe Support cast to string 2020-05-10 15:42:16 -04:00
Wilson Snyder d4a631446b Fix crash in unroller on increment-only while loops. 2020-05-10 15:26:41 -04:00
Wilson Snyder a2cc053c6f Tests: Fix t_math_svl.pl 2020-05-10 15:19:38 -04:00
Wilson Snyder 8998ffc4e5 Support reporting some fork syntax errors. 2020-05-10 15:01:43 -04:00
Wilson Snyder ca162716c6 Internals: clang-format 2020-05-10 14:29:15 -04:00
Wilson Snyder 629dd16714 Tests: Rename t_delay_func_bad 2020-05-10 14:28:42 -04:00
Wilson Snyder 12b903caf4 Improve error on using array.unique method. 2020-05-10 14:28:42 -04:00
Yossi Nivin f9a0cf0cff Support $countbits (#2287) 2020-05-10 14:27:22 -04:00
Wilson Snyder 070bcddf5a Support unpacked array .sum and .product. 2020-05-10 12:48:33 -04:00
Wilson Snyder feb1e2bd48 Commentary 2020-05-10 11:01:57 -04:00
Wilson Snyder 6e7ee23644 Internals: Code cleanups. 2020-05-09 15:00:46 -04:00
Wilson Snyder c00cc18d37 Optimize dead code after gotos 2020-05-09 15:00:36 -04:00
Wilson Snyder a7e17a8855 Fix double conversion on half of conditional. 2020-05-08 21:35:45 -04:00
Wilson Snyder 60fa1db731 Tests: Trivial cleanup 2020-05-08 21:35:45 -04:00
Geza Lore ac09ad3ffd Minor improvements to DPI open array handling (#2316)
- Allow arbitrary number of open array dimensions, not just 3. Note
right now this only works with the array querying functions specified
in IEEE 1800-2017 H.12.2
- Issue error when passing dynamic array or queue as DPI open array
(currently unsupported)
- Also tweaked AstVar::vlArgTypeRecurse, which should now error or fail
for unsupported types.
2020-05-08 18:22:44 +01:00
Wilson Snyder 27953e26b6 Backout example change. 2020-05-08 07:35:54 -04:00
Wilson Snyder 9375d9f603 Fix $isunknown with constant Zs. 2020-05-07 21:40:08 -04:00
Wilson Snyder 72bd91c7f1 Support $isunbounded and parameter $. (#2104) 2020-05-07 21:12:58 -04:00
Wilson Snyder 8850ca962e Fix newish error to use standard parens to ref IEEE. 2020-05-07 21:12:58 -04:00
Wilson Snyder 7fd590f855 Commentary 2020-05-07 21:12:58 -04:00
Wilson Snyder 5f7ae1fbce wip 2020-05-07 21:04:26 -04:00
Wilson Snyder b56a25e89c Fix newish error to use standard parens to ref IEEE. 2020-05-07 18:21:11 -04:00
Wilson Snyder 4f32b093e6 Commentary 2020-05-07 18:11:06 -04:00
Geza Lore 6a54fb6f96 Modify std::multimap in V3Combine safely.
We used to iterate the m_callMmap std::multimap by getting limit
iterators from equal_range, but we also modify the same map in the loop
which invalidates those limit iterators. Note this only caused actual
problems if the new AstCCall inserted via 'addCall' in the loop had a
memory address (which is used as the key) which fell into the range
returned by equal_range, so was pretty hard to trigger.
2020-05-07 14:31:43 +01:00
Wilson Snyder 546ccd56c4 Internals: Enable future JumpGo to non-end. No functional change intended. 2020-05-06 21:33:05 -04:00
Wilson Snyder ca77a93214 Add lint check for bad delay locations. 2020-05-06 19:25:13 -04:00
Dan Petrisko ee1b20e1cd Adding missing sstream include (#2312) 2020-05-06 19:16:41 -04:00
Yutetsu TAKATSUKASA aa86e0bbc0 Support 'E', 'p', and 'P' when overriding floating point parameter. (#2310) 2020-05-06 07:45:07 -04:00
Wilson Snyder b6b3482010 Internals: Use typ delay by default 2020-05-05 20:42:19 -04:00
Wilson Snyder 05aecd2c0b Internals: Fix tabs in astgen. No effective functional change. 2020-05-05 20:33:35 -04:00
Wilson Snyder 6ab3d8f3ed Internals: Refactor to add AstNodeProcedure. No functional change intended. 2020-05-05 19:12:36 -04:00
Wilson Snyder 0fcc7f2987 Fix default pkgconfig version to have no spaces (#2308) 2020-05-05 08:46:24 -04:00
Wilson Snyder 7d7e67b49b Show Verilog reference on V3Number asserts. 2020-05-04 19:57:21 -04:00
Wilson Snyder a41ea180fa Fix +: and -: on unpacked arrays. (#2304) 2020-05-04 19:40:50 -04:00
Wilson Snyder 98889b3f4e Tests: Fix permission 2020-05-04 19:35:48 -04:00
Tim Snyder 83fbfa8c71 Fix /usr/bin/env perl in lieu of /usr/bin/perl (#2307)
Enables scripts to work where perl is not installed at /usr/bin/perl
2020-05-04 19:27:30 -04:00
Tim Snyder a57262d6e7 Fix use /usr/bin/env perl in lieu of /usr/bin/perl (#2306)
Enables scripts to work where perl is not installed at /usr/bin/perl
2020-05-04 18:42:15 -04:00
Geza Lore fe708f045a Fix Travis oddity 2020-05-04 00:21:07 +01:00
Geza Lore 8afcd67a1f Fix FST tracing of little endian vectors 2020-05-03 22:39:45 +01:00
Wilson Snyder 16e258eb4c Commentary: reformat changes, relocate announcements 2020-05-03 16:10:02 -04:00
Wilson Snyder d6fbbddac9 devel release 2020-05-03 11:18:53 -04:00
Wilson Snyder 9dc65df982 Version bump 2020-05-03 11:14:37 -04:00
Wilson Snyder 8f64e4a76f Support $root, #2150. 2020-05-02 08:29:20 -04:00
John Demme 6e9008fb5a Fix VerilatedVarProps::totalSize missing the first unpacked dim (#2296) 2020-05-01 07:42:29 -04:00
Wilson Snyder 5ded80cf79 Fix MacOs Homebrew by removing default LIBS, #2298. 2020-04-30 19:53:21 -04:00
Wilson Snyder a6deee2083 Fix clock enables with bit-extends, #2299. 2020-04-30 19:22:58 -04:00
Wilson Snyder e1f45dd84a Commentary 2020-04-30 18:52:32 -04:00
Wilson Snyder 9fd4541069 Fix reduction OR on wide data, broke in v4.026, #2300. 2020-04-30 17:53:54 -04:00
Geza Lore 849487da23 Modify --build to be a standalone option (#2294)
- Issue an error when --build is used together with --make
- When given --build, always use GNU Make to perform the build
- Update documentation (examples were good as they were)
- Remove the broken t_flag_build_cmake test

Fixes #2280
2020-04-30 12:54:50 +01:00
Peter Horvath dc64b43152 Fix xcode clang bug workaround (#2295) 2020-04-30 07:20:31 -04:00
Geza Lore 209a585a68 Remove VL_NEGATE_{I,Q,E}, use C native unary '-' instead
This is to avoid slowing down -O0 models unnecessarily.
2020-04-30 01:05:52 +01:00
Geza Lore aa9cde22c8 Use SIMD intrinsics to render VCD traces (#2289)
Use SIMD intrinsics to render VCD traces.

I have measured 10-40% single threaded performance increase with VCD
tracing on SweRV EH1 and lowRISC Ibex using SSE2 intrinsics to render
the trace. Also helps a tiny bit with FST, but now almost all of the FST
overhead is in the FST library.

I have reworked the tracing routines to use more precisely sized
arguments. The nice thing about this is that the performance without the
intrinsics is pretty much the same as it was before, as we do at most 2x
as much work as necessary, but in exchange there are no data dependent
branches at all.
2020-04-30 00:09:09 +01:00
Wilson Snyder faf7255e83 Commentary 2020-04-29 18:42:28 -04:00
Wilson Snyder a6c97cc3bc Commentary 2020-04-29 18:41:00 -04:00
Wilson Snyder 977ceb404d Mention -march-native, #2289. 2020-04-29 18:10:43 -04:00
Wilson Snyder b44efe7ef7 Use 'suggest' for consistent wording. 2020-04-28 21:19:19 -04:00
Wilson Snyder 15ad3f46be Fix logical not optimization with empty begin, #2291. 2020-04-28 21:15:20 -04:00
Wilson Snyder c6d1a9858a Use clang-format 10.0.0 2020-04-28 18:47:59 -04:00
Wilson Snyder 77cc335c2d Commentary 2020-04-28 18:47:49 -04:00
Wilson Snyder a95eb53684 Commentary (#2290). 2020-04-28 18:46:59 -04:00
Wilson Snyder 910803e6db Fix error on unpacked connecting to packed, #2288. 2020-04-27 18:38:54 -04:00
Geza Lore dd967f7769 Improve trace buffer memory utilization and performance.
Convert trace buffer to 32-bit entries, rather than a union containing a
pointer type. Also tweaked trace entry layouts for a bit more
performance. This gains another 10% on SweRV EH1 CoreMark.
2020-04-27 19:00:17 +01:00
Geza Lore b79ef672e1 Various minor optimizations of VCD trace routines
- Change templated trace routines to branch table.

Removed templating from trace chgBus and fullBus and replaced them with
a branch table like the other there is a very small (< 1%) penalty for
this on SwerRV EH1 CoreMark, but this is less than the variability of
disk IO so it's worth it to keep the code simpler and smaller.

- Prefetch VCD suffix buffer at the top of emit*

- Increase ILP in VCD emit* routines

- Use a 64-bit unaligned store to emit the VCD suffix (on x86 only)

The performance difference with these is very small, but the changes
hopefully make this code more performance-portable across various
micro-architectures.
2020-04-27 18:44:53 +01:00
Wilson Snyder 70549e1a64 Internals: Parse lifetime directives; still unsupported. 2020-04-26 12:45:06 -04:00
Wilson Snyder 87e1c36e4a Support event data type (with some restrictions). 2020-04-25 15:37:46 -04:00
Geza Lore 9991b19610 Another attempt at flushing threaded VCD correctly. 2020-04-25 18:40:09 +01:00
Geza Lore 1381d3dbde Add -Wno-tautological-bitwise-compare to model build flags (#2285)
This appeases Clang 10.
2020-04-25 16:29:42 +01:00
Wilson Snyder 5e575f5906 Fix line numbers in tables. 2020-04-24 19:34:26 -04:00
Wilson Snyder e2cbcd37d8 Commentary 2020-04-24 18:43:02 -04:00
Wilson Snyder 3b37b5b92d Tests: Check output from some unsupported tests. 2020-04-24 08:22:19 -04:00
Geza Lore 10b4678ee6 Make vgen.pl deterministic 2020-04-24 04:53:33 +01:00
Geza Lore c1665818b9 Fix missing flush with threaded VCD tracing. (#2282)
VerilatedVcdC::openNext() failed to flush the tracing thread before
opening the next output file, which caused t_trace_cat.pl to fail
with --vltmt on occasion.
2020-04-24 03:09:26 +01:00
Geza Lore 27f4399c31 Fix tests failing on rerun after passing from clean. (#2281) 2020-04-23 21:27:06 -04:00
Wilson Snyder df52e481fb Collected minor output code cleanups. 2020-04-23 21:22:47 -04:00
Wilson Snyder f93ae707e0 Tests: Add bad option test. 2020-04-23 19:56:26 -04:00
Geza Lore 6ed10b7fde Fix --protect-lib generated library link rules (#2279)
We used to include a .cpp file on the link line for the shared library,
which was ignored, but generated a .d file for the .so which contained
the header files required by the .cpp file. This then caused a rebuild
where we included the .d in verilated.mk to included in the .h headers
among the prerequisites of the .so, yielding a clang error about treating
.h files as c++-header rather than c-header... Long story short, we don't
do that anymore. This used t cause t_a4_examples to fail on occasion.

Note there is no need for a separate compilation rule for the
<--protect-lib>.cpp, as it will jsut pick up the standard OPT_FAST rule.
2020-04-23 17:30:23 -04:00
Geza Lore 8208fe8a0e Fix test failures on Ubuntu 20.04 (#2278)
- Packaged SystemC lives in /usr so needed to update regex in test
driver
- Clang 10 complains about mixed named and positional initializers in
struct definitions.
2020-04-23 17:29:37 -04:00
Wilson Snyder ace35b3e81 Tests: Add -G test. 2020-04-23 08:05:14 -04:00
Wilson Snyder 2b58e834ee Tests: Rename IVERILOG define for consistency. No functional change. 2020-04-23 08:05:14 -04:00
Qingyao Sun 14643643c9 Fix compatibility problem with CMake policy CMP0025 (#2277)
Signed-off-by: Qingyao Sun <[email protected]>
2020-04-23 07:14:20 -04:00
Wilson Snyder 7176aee852 Internals: Parse fork and delays, but then still report unsupported. 2020-04-22 21:31:40 -04:00
Geza Lore c96a43b452 Fix unused variable in VL_READMEM_N (#2274) 2020-04-22 17:25:35 -04:00
Wilson Snyder 77915f78db Add experimental-only option. 2020-04-21 20:45:23 -04:00
Geza Lore c52f3349d1 Initial implementation of generic multithreaded tracing (#2269)
The --trace-threads option can now be used to perform tracing on a
thread separate from the main thread when using VCD tracing (with
--trace-threads 1). For FST tracing --trace-threads can be 1 or 2, and
--trace-fst --trace-threads 1 is the same a what --trace-fst-threads
used to be (which is now deprecated).

Performance numbers on SweRV EH1 CoreMark, clang 6.0.0, Intel i7-3770 @
3.40GHz, IO to ramdisk, with numactl set to schedule threads on different
physical cores. Relative speedup:

--trace     ->  --trace --trace-threads 1      +22%
--trace-fst ->  --trace-fst --trace-threads 1  +38% (as --trace-fst-thread)
--trace-fst ->  --trace-fst --trace-threads 2  +93%

Speed relative to --trace with no threaded tracing:
--trace                                 1.00 x
--trace --trace-threads 1               0.82 x
--trace-fst                             1.79 x
--trace-fst --trace-threads 1           1.23 x
--trace-fst --trace-threads 2           0.87 x

This means FST tracing with 2 extra threads is now faster than single
threaded VCD tracing, and is on par with threaded VCD tracing. You do
pay for it in total compute though as --trace-fst --trace-threads 2 uses
about 240% CPU vs 150% for --trace-fst --trace-threads 1, and 155% for
--trace --trace threads 1. Still for interactive use it should be
helpful with large designs.
2020-04-21 23:49:07 +01:00
Wilson Snyder 6ab51de96d Fix dockerfile 2020-04-21 18:37:53 -04:00
James Hanlon 97cbc10925 Add --flaten for use with --xml-only (#2270). 2020-04-21 18:14:08 -04:00
James Hanlon 65cd4f6047 Fix comment and add to CONTRIBUTORS (#2270). 2020-04-21 18:11:53 -04:00
Wilson Snyder 174fd1bf0e Codacy cleanups. No functional change. 2020-04-20 22:01:47 -04:00
Wilson Snyder b12413e42f Tests: Reenable some tests incorrectly marked unsupported. 2020-04-20 21:55:23 -04:00
Wilson Snyder 7709130d93 Fix Codacy badge 2020-04-20 21:52:29 -04:00
Wilson Snyder 15f7685755 Codacity cleanups. No functional change intended. 2020-04-20 21:43:05 -04:00
Wilson Snyder 83c6e9e821 Commentary commit for Codacity. 2020-04-20 21:13:43 -04:00
Veripool API Bot 1cacb1deab Commentary commit for Codacity. 2020-04-20 20:01:59 -04:00
Veripool API Bot 03bc8b7480 Commentary commit for Codacity. 2020-04-20 19:54:07 -04:00
Veripool API Bot 7d6668a3bd Commentary commit for Codacity. 2020-04-20 19:38:21 -04:00
Wilson Snyder def40fab9b Internals: Rename VSigning 2020-04-19 21:19:09 -04:00
Wilson Snyder fceedd9f4d Tests: Update static test. 2020-04-19 21:18:57 -04:00
Wilson Snyder 4272f2116e Tests: Update static test. 2020-04-19 20:10:07 -04:00
Geza Lore 39d903375b Factor out trace implementation common to all formats. (#2268)
This patch de-duplicates common functionality between the VCD and FST
trace implementation. It also enables adding new trace formats more
easily and consistently.

No functional nor performance change intended.
2020-04-19 23:57:36 +01:00
Wilson Snyder 9164eb03d5 Show that class parameters even if unused are unsupported. 2020-04-19 18:36:55 -04:00
Wilson Snyder 7b789fe02a Docker: Add ccache and libgoogle-perftools-dev 2020-04-19 12:59:38 -04:00
Wilson Snyder 4ae3d3af71 Fix docker build error 2020-04-19 12:43:20 -04:00
Geza Lore 6a54922044 Set FST timescale correctly. (#2266)
The FST trace timescale used to be set in the constructor via
set_time_unit, but at that point we haven't normally opened the
file yet so it was just dropped. On top of that, we actually want
to use set_time_resolution... FST trace timescales now match the VCD.
2020-04-19 08:47:22 -04:00
Wilson Snyder 466535abdc Support direct class member init. 2020-04-18 20:20:17 -04:00
Geza Lore efacac2e3d Tests: Ignore SystemC file paths in expected test results (#2265) 2020-04-18 18:56:19 -04:00
Geza Lore 74e16d85c5 Fix FST trace initial time stamp. (#2264)
If the first dump was not at time zero, then the FST trace used
to contain the initial values as if they were set at time zero. Now
they only appear at the time the first dump call is actually made,
and hence match the VCD trace exactly.
2020-04-18 18:54:02 -04:00
Wilson Snyder 39d7cbf412 Fix arrayed instances connecting to slices, #2263. 2020-04-17 19:30:53 -04:00
Wilson Snyder 8f7e463656 Tests: Fix makeflag test, was failing older makes. 2020-04-16 17:31:41 -04:00
Wilson Snyder e6f345e45d Internal: clang-tidy fixes. No functional change. 2020-04-15 21:47:37 -04:00
Wilson Snyder d4f7f5297a Support IEEE time units and time precisions, #234. (#2253)
Includes `timescale, $printtimescale, $timeformat.
VL_TIME_MULTIPLIER, VL_TIME_PRECISION, VL_TIME_UNIT have been removed
and the time precision must now match the SystemC time precision.
To get closer behavior to older versions, use e.g. --timescale-override
"1ps/1ps".
2020-04-15 19:39:03 -04:00
Wilson Snyder 9b8aebb00c Commentary on --build 2020-04-15 18:08:37 -04:00
Wilson Snyder 58091edd68 Tests: Fix cmake -j unknown 2020-04-15 18:08:31 -04:00
Yutetsu TAKATSUKASA 18412f9322 Add --build option to call make/cmake as subprocess (#2249)
* Add --build, -j, -MAKEFLAGS, and --no-verilate options
* Verilator: Can build on both gmake and cmake
2020-04-15 17:44:21 -04:00
Wilson Snyder 1883ab29cb clang-format 10.0 forward compatibility. No functional change. 2020-04-15 17:36:57 -04:00
Geza Lore 1a64c7d232 Fix run-time formatting of variable wider than 1023 bits (#2261) 2020-04-15 17:26:15 -04:00
Wilson Snyder f3308d236b clang-format remaining sources. No functional change. 2020-04-15 07:58:34 -04:00
Wilson Snyder 1b94e3b0e2 Internals: clang-format files needed for #2249. 2020-04-14 19:55:00 -04:00
Geza Lore 08b74e5ab9 Fix crash when formatting constant wider than 1023 bits (#2260) 2020-04-14 18:07:09 -04:00
Wilson Snyder 5c966ec510 clang-format many files. No functional change.
Use nodist/clang_formatter to reformat files that are now clean.
2020-04-13 22:52:23 -04:00
Geza Lore dc5c259069 Improve tracing performance. (#2257)
* Improve tracing performance.

Various tactics used to improve performance of both VCD and FST tracing:
- Both: Change tracing functions to templates to take variable widths as
  template parameters. For VCD, subsequently specialize these to the
  values used by Verilator. This avoids redundant instructions and hard
  to predict branches.
- Both: Check for value changes via direct pointer access into the
  previous signal value buffer. This eliminates a lot of simple pointer
  arithmetic instructions form the tracing code.
- Both: Verilator provides clean input, no need to mask out used bits.
- VCD: pre-compute identifier codes and use memory copy instead of
  re-computing them every time a code is emitted. This saves a lot of
  instructions and hard to predict branches. The added D-cache misses
  are cheaper than the removed branches/instructions.
- VCD: re-write the routines emitting the changes to be more efficient.
- FST: Use previous signal value buffer the same way as the VCD tracing
  code, and only call the FST API when a change is detected.

Performance as measured on SweRV EH1, with the pre-canned CoreMark
benchmark running from DCCM/ICCM, clang 6.0.0, Intel i7-3770 @ 3.40GHz,
and IO to ramdisk:

            +--------------+---------------+----------------------+
            | VCD          | FST           | FST separate thread  |
            | (--trace)    | (--trace-fst) | (--trace-fst-thread) |
------------+-----------------------------------------------------+
Before      |  30.2 s      | 121.1 s       |  69.8 s              |
============+==============+===============+======================+
After       |  24.7 s      |  45.7 s       |  32.4 s              |
------------+--------------+---------------+----------------------+
Speedup     |    22 %      |   256 %       |   215 %              |
------------+--------------+---------------+----------------------+
Rel. to VCD |     1 x      |  1.85 x       |  1.31 x              |
------------+--------------+---------------+----------------------+

In addition, FST trace size for the above reduced by 48%.
2020-04-14 00:13:10 +01:00
Wilson Snyder dc27a179e2 Always define VL_SIG etc; conditional definitions were long removed SystemPerl. 2020-04-13 19:07:56 -04:00
Wilson Snyder 236e6baa76 clang-format: Loops allowed on single line. 2020-04-13 17:44:19 -04:00
Wilson Snyder dba88bae3c Support class new. 2020-04-12 18:57:12 -04:00
Wilson Snyder d4b6e2b2b5 Internals: NodeModule for packages. 2020-04-12 14:53:10 -04:00
Wilson Snyder 1e2d73fc80 Internals: clang-format and refactor taskref pin handling. 2020-04-12 08:26:14 -04:00
Wilson Snyder ea3acc2d3a Fix --skip-identical broke recent commit. 2020-04-11 20:22:57 -04:00
Nathan Kohagen 152505e879 Fix make install/uninstall for examples/xml_py, #2252. 2020-04-11 18:11:53 -04:00
Wilson Snyder 8e6674066f Tests: Clean before rerunning failing test. 2020-04-11 11:40:15 -04:00
Geza Lore 8b2666cd04 Fix to make trace code allocation dense. (#2250)
This looks like a bits/bytes bug. The affected m_codeInc member
determines how many 32-bit words to allocate in a buffer used to store
previous values of the signal, but this was off by a factor of 8, so
we used to use too much memory.

SweRV VCD tracing speed +6.5% (excluding IO, clang 6.0), due mainly to
reduced D cache misses.
2020-04-11 16:00:43 +01:00
Wilson Snyder afa8e4c786 Internals: Favor const_iterator. No functional change. 2020-04-11 10:54:42 -04:00
Wilson Snyder ef211fc9e0 Make sure SystemC always included in -sc mode to prevent ordering issues. 2020-04-11 10:33:40 -04:00
Wilson Snyder 1a6c2fc55d Fix class members getting misoptimized away. 2020-04-10 21:10:21 -04:00
Wilson Snyder 15b40a97d9 Support `unconnected_drive 2020-04-09 23:26:03 -04:00
Wilson Snyder 343db78c03 Fix including verilated_sc in Syms to fix compile order problem exposed in #2237. 2020-04-09 23:03:47 -04:00
Nathan Myers 4c1ae4701a Add assertion for monotonic dump times #2103 (#2237) 2020-04-09 19:00:27 -04:00
Geza Lore 05f213c266 VCD tracing speed improvements (#2246)
* Don't inline VCD dump functions

Improves model speed with tracing. Measured on SweRW cmark:
- GCC 5.5      ~3% faster
- Clang 6.0    ~12% faster (!)

* Remove redundant test from VCD bit tracing.

Improves model speed with tracing. Measured on SweRW cmark:
 - GCC 5.5      ~7.5% faster
 - Clang 6.0    ~1.5% faster
2020-04-09 08:19:26 -04:00
Geza Lore 0f617988d4 Compile fast tracing code with OPT_FAST in single compile mode. (#2245)
When using the __ALL*.cpp based single compile mode (i.e.: without
VM_PARALLEL_BUILDS), the fast path tracing code used to be included in
__Allsup.cpp, which was compiled with OPT_SLOW, severely harming tracing
performance. We now have __ALLfast.cpp and __ALLslow.cpp instead of
__ALLcls.cpp and __ALLsup.cpp, so we can compile the fast support code
with OPT_FAST as well.
2020-04-08 21:05:43 -04:00
Wilson Snyder 1e0b37f4bc Commentary 2020-04-08 17:55:12 -04:00
Geza Lore 991d8b178b Fix FST tracing performance by removing std::map from hot path. (#2244)
This patch eliminates a major piece of inefficiency in FST tracing
support, by using an array to lookup fstHandle values corresponding
to trace codes, instead of a tree based std::map. With this change, FST
tracing is now only about 3x slower than VCD tracing. We do require
more memory to store the symbol lookup table, but the size of that is
still small, for the speed benefit.
2020-04-08 17:54:35 -04:00
Wilson Snyder 608d5a87d1 tests: Avoid assuming a timescale. 2020-04-07 20:55:47 -04:00
Wilson Snyder 914a6edd33 Add error if use SystemC 2.2 and earlier (pre-2011) as is deprecated. 2020-04-07 19:58:17 -04:00
Geza Lore 0cfa828572 Fix DPI import/export to be standard compliant, #2236. 2020-04-07 19:07:47 -04:00
Wilson Snyder 4556b6c022 Fix clang warning. 2020-04-07 12:17:48 -04:00
Wilson Snyder cba05480ba Fix clang warning. 2020-04-06 20:13:24 -04:00
Wilson Snyder 2abbae8dd0 Internals: Remove strncpy to appease codacity. 2020-04-06 19:26:31 -04:00
Wilson Snyder f13bd1aec4 Fix clang unused warning. 2020-04-06 08:53:19 -04:00
Wilson Snyder b6c21ad21a Fix duplicate traces with $dumpfile, part of #2237. 2020-04-06 08:33:51 -04:00
Wilson Snyder 26301a4133 Commentary 2020-04-06 08:19:32 -04:00
Wilson Snyder 383f9832d4 Tests: Standardize verilog indentation. 2020-04-05 21:53:24 -04:00
Wilson Snyder 50535a1894 Internals: cppcheck 1.90 fixes. No functional change intended. 2020-04-05 18:57:47 -04:00
Wilson Snyder ff31abe341 Commenary 2020-04-05 17:01:33 -04:00
Wilson Snyder 763f621d4c Deprecate VL_ULL. 2020-04-05 16:45:53 -04:00
Wilson Snyder d922cae0a2 Commentary 2020-04-05 16:13:41 -04:00
Wilson Snyder efaf375887 Configuring with ccache present now defaults to using it; see OBJCACHE in the manual. 2020-04-05 16:10:33 -04:00
Wilson Snyder 5932eae32a Commentary 2020-04-05 16:09:18 -04:00
Wilson Snyder a331397954 Fix real conversion from constant with X/Z. 2020-04-05 11:56:15 -04:00
Wilson Snyder a494ad5ec7 Support $ferror, #1638. 2020-04-05 11:22:05 -04:00
Wilson Snyder b617cd5549 Internals: Add V3ERROR_NA_RETURN. No functional change. 2020-04-05 10:26:53 -04:00
Wilson Snyder e55338f927 Support $fflush without arguments, #1638. 2020-04-05 10:11:28 -04:00
Wilson Snyder 6eadb8e771 Add simplistic class support with many restrictions, see manual, #377. 2020-04-05 09:30:23 -04:00
Wilson Snyder f6048cc9c1 Fix clang warning. No functional change. 2020-04-05 08:22:51 -04:00
Wilson Snyder 9fdb026e95 Add VM_C11 for future need of C++11 2020-04-04 20:48:03 -04:00
Wilson Snyder bf17bb4648 Fix codacity warnings 2020-04-04 20:08:58 -04:00
Veripool API Bot 4dc1f40856 Update contributors for codacity 2020-04-04 18:02:23 -04:00
Wilson Snyder 5302a9d0e6 Internals: clang-format cleanups. No functional change. 2020-04-04 17:55:37 -04:00
Wilson Snyder e07e9390f6 Internals: clang-format cleanups. No functional change. 2020-04-04 14:09:21 -04:00
Wilson Snyder a13eab55f5 Internals: Add missing VL_DO_CLEARs. No functional change. 2020-04-04 13:06:31 -04:00
Wilson Snyder b2228afd1a devel release 2020-04-04 08:50:56 -04:00
2622 changed files with 101621 additions and 48666 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
@@ -104,7 +104,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
+1 -1
View File
@@ -1,4 +1,4 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-modernize*,-hicpp*,-android-cloexec-fopen,-cert-dcl50-cpp,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-security*,-cppcoreguidelines-no-malloc,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-special-member-functions,-fuchsia-default-arguments,-fuchsia-overloaded-operator,-google-default-arguments,-google-readability-todo,-google-runtime-references,-llvm-header-guard,-llvm-include-order,-misc-string-integer-assignment,-misc-string-literal-with-embedded-nul,-readability-braces-around-statements,-readability-container-size-empty,-readability-delete-null-pointer,-readability-else-after-return,-readability-implicit-bool-conversion,-readability-named-parameter,-readability-static-accessed-through-instance'
Checks: '*,-hicpp*,-android-cloexec-fopen,-cert-dcl50-cpp,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-security*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-no-malloc,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-special-member-functions,-fuchsia-*,-google-default-arguments,-google-readability-todo,-google-runtime-references,-llvm-header-guard,-llvm-include-order,-misc-string-integer-assignment,-misc-string-literal-with-embedded-nul,-modernize-use-auto,-modernize-use-trailing-return-type,-readability-braces-around-statements,-readability-container-size-empty,-readability-delete-null-pointer,-readability-else-after-return,-readability-implicit-bool-conversion,-readability-named-parameter,-readability-static-accessed-through-instance'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
+1
View File
@@ -3,3 +3,4 @@ exclude_paths:
- '.github/**'
- 'ci/build_verilator.sh'
- 'include/vltstd/**'
- 'nodist/fastcov.py'
+4 -2
View File
@@ -1,6 +1,6 @@
---
name: Bug report
about: Something isn't working as expected, and it isn't "Unsupported." (Note our contributor agreement at https://github.com/verilator/verilator/.github/blob/master/CONTRIBUTING.adoc)
about: Something isn't working as expected, and it isn't "Unsupported." (Note our contributor agreement at https://github.com/verilator/verilator/blob/master/docs/CONTRIBUTING.adoc)
title: ''
labels: new
assignees: ''
@@ -11,4 +11,6 @@ Thanks for taking the time to report this.
Can you attach an example that shows the issue? (Must be openly licensed, ideally in test_regress format.)
May we assist you in trying to fix this yourself?
What 'verilator --version' are you using? Did you try it with the git master version?
Would you be willing to try to fix Verilator yourself with assistance?
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: Feature Request
about: Request something should be supported, or a new feature added. (Note our contributor agreement at https://github.com/verilator/verilator/.github/blob/master/CONTRIBUTING.adoc)
about: Request something should be supported, or a new feature added. (Note our contributor agreement at https://github.com/verilator/verilator/blob/master/docs/CONTRIBUTING.adoc)
title: ''
labels: new
assignees: ''
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: Q and A, or Other
about: Ask a question, not related to a specific bug or feature request. (Note our contributor agreement at https://github.com/verilator/verilator/.github/blob/master/CONTRIBUTING.adoc)
about: Ask a question, not related to a specific bug or feature request. (Note our contributor agreement at https://github.com/verilator/verilator/blob/master/docs/CONTRIBUTING.adoc)
title: ''
labels: new
assignees: ''
+137
View File
@@ -0,0 +1,137 @@
# DESCRIPTION: Github actions config
# This name is key to badges in README.adoc, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: build
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # weekly
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 2Gi # 2GiB for clang and gcc, 4GiB in total
jobs:
Matrix:
runs-on: ubuntu-latest
name: Generate Build matrix
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: generate
name: Run 'generate_matrix.sh'
run: |
if [ '${{ github.event_name}}' = 'pull_request' ]; then
matrix='[ "ubuntu-20.04" ]'
else
matrix='[ "ubuntu-16.04", "ubuntu-18.04", "ubuntu-20.04" ]'
fi
echo "::set-output name=matrix::$matrix"
Build:
needs: Matrix
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
debug: [ opt, dbg ]
compiler:
- { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ }
runs-on: ${{ matrix.os }}
name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.debug }}
env:
CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ${{ matrix.os }}
CI_MAKE_SRC_TARGET: ${{ matrix.debug }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_KEY: ${{ matrix.os }}-${{ matrix.compiler.cc }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
env:
cache-name: ccache
with:
path: ${{ github.workspace }}/.ccache
key: ${{ env.CACHE_KEY }}-${{ env.cache-name }}-${{ github.sha }}
restore-keys: ${{ env.CACHE_KEY }}-${{ env.cache-name }}
- name: Install packages for build
run: ./ci/ci-install.bash
- name: Build
run: |
./ci/ci-script.bash
tar cvzf verilator-${{ matrix.os}}-${CI_COMMIT}-${{ matrix.compiler.cc }}-${{ matrix.debug }}.tgz ./bin
- uses: actions/upload-artifact@v2
with:
path: verilator-${{ matrix.os}}-${{ env.CI_COMMIT }}-${{ matrix.compiler.cc }}-${{ matrix.debug }}.tgz
Test:
needs: [ Matrix, Build ]
strategy:
fail-fast: false
max-parallel: 8
matrix:
os: ${{ fromJson(needs.Matrix.outputs.matrix) }}
compiler:
- { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ }
suite:
- dist-vlt-0
- dist-vlt-1
- vltmt-0
- vltmt-1
runs-on: ${{ matrix.os }}
name: Test | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.suite }}
env:
CI_BUILD_STAGE_NAME: test
CI_RUNS_ON: ${{ matrix.os }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_KEY: ${{ matrix.os }}-${{ matrix.compiler.cc }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
env:
cache-name: ccache
with:
path: ${{ github.workspace }}/.ccache
key: ${{ env.CACHE_KEY }}-${{ env.cache-name }}-${{ github.sha }}
restore-keys: ${{ env.CACHE_KEY }}-${{ env.cache-name }}
- uses: actions/download-artifact@v2
- name: Install Verilator and test dependencies
run: |
tar xvzf artifact/verilator-${{ matrix.os}}-${CI_COMMIT}-${{ matrix.compiler.cc }}-opt.tgz
tar xvzf artifact/verilator-${{ matrix.os}}-${CI_COMMIT}-${{ matrix.compiler.cc }}-dbg.tgz
rm -rf artifact
./ci/ci-install.bash
- name: Test
env:
TESTS: ${{ matrix.suite }}
run: ./ci/ci-script.bash
+44
View File
@@ -0,0 +1,44 @@
# DESCRIPTION: Github actions config
# This name is key to badges in README.adoc, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: clang-format
on:
push:
pull_request_target:
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-20.04
name: Ubuntu 20.04 | format
env:
CI_OS_NAME: linux
CI_RUNS_ON: ubuntu-20.04
CI_COMMIT: ${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install packages for build
env:
CI_BUILD_STAGE_NAME: build
run: |
bash ci/ci-install.bash &&
sudo apt-get install clang-10 yapf3 &&
git config --global user.email "[email protected]" &&
git config --global user.name "github action"
- name: Format code
run: |
autoconf &&
./configure &&
make -j 2 format CLANGFORMAT=clang-format-10 &&
git status
- name: Push
run: |
if [ -n "$(git status --porcelain)" ]; then
git commit . -m "Apply clang-format" &&
git push origin
fi
+17
View File
@@ -0,0 +1,17 @@
# DESCRIPTION: Github actions config
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: Contributor Agreement
on:
push:
pull_request:
workflow_dispatch:
jobs:
Test:
name: "'docs/CONTRIBUTORS' was signed"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: test_regress/t/t_dist_contributors.pl
+98
View File
@@ -0,0 +1,98 @@
# DESCRIPTION: Github actions config
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: coverage
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # weekly
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 2Gi # 2GiB for clang and gcc, 4GiB in total
COVERAGE: 1
jobs:
Build:
runs-on: ubuntu-20.04
env:
CI_BUILD_STAGE_NAME: build
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
env:
cache-name: ccache
with:
path: ${{ github.workspace }}/.ccache
key: coverage-${{ env.cache-name }}-${{ github.sha }}
restore-keys: coverage-${{ env.cache-name }}
- name: Install dependencies for build
env:
CI_BUILD_STAGE_NAME: build
run: ./ci/ci-install.bash
- name: Build Verilator
run: |
./ci/ci-script.bash
mkdir tarball/
cp -vr bin tarball/
cp -vr src/obj*/*.gcno tarball/
tar cvzf verilator-${CI_COMMIT}.tgz -C ./tarball .
- uses: actions/upload-artifact@v2
with:
path: verilator-${{ env.CI_COMMIT }}.tgz
Test:
needs: Build
strategy:
fail-fast: false
matrix:
test:
- vlt-
- vltmt-
num:
- 0
- 1
- 2
- 3
include:
- { test: dist, num: '' }
name: test-${{ matrix.test }}${{ matrix.num }}
runs-on: ubuntu-20.04
env:
CI_BUILD_STAGE_NAME: test
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
env:
cache-name: ccache
with:
path: ${{ github.workspace }}/.ccache
key: coverage-${{ env.cache-name }}-${{ github.sha }}
restore-keys: coverage-${{ env.cache-name }}
- uses: actions/download-artifact@v2
- name: Install Verilator and test dependencies
run: |
tar xvzf artifact/verilator-${CI_COMMIT}.tgz
./ci/ci-install.bash
- name: Test
env:
TESTS: coverage-${{ matrix.test }}${{ matrix.num }}
run: ./ci/ci-script.bash
+3
View File
@@ -1,5 +1,6 @@
\#*
.#*
.nfs*
*~
*.tidy
*.old
@@ -14,6 +15,8 @@
*.tex
*.pdf
/Makefile
/.ccache
/artifact/
README
TAGS
autom4te.cache
-187
View File
@@ -1,187 +0,0 @@
# DESCRIPTION: Travis-CI config
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
version: ~> 1.0
os: linux
language: cpp
cache: ccache
env:
global:
- VERILATOR_CACHE=$HOME/verilator_cache
- VERILATOR_ROOT=$PWD
- VERILATOR_NUM_JOBS=$(echo `nproc` + 1 | bc)
- VERILATOR_CONFIG_FLAGS="--enable-maintainer-mode --enable-longtests"
- VERILATOR_AUTHOR_SITE=1
- OBJCACHE=ccache
cache:
directories:
- $VERILATOR_CACHE
before_install:
# Perl modules needed for testing
# Not listing Bit::Vector as slow to install, and only skips one test
- yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
- sudo apt-get install gdb gtkwave
- sudo apt-get install libgoogle-perftools-dev
before_script:
- bash -x ci/build_vcddiff.sh
- bash -x ci/build_verilator.sh
after_script:
- ccache -s
stages:
- "Build Verilator"
- test
jobs:
include:
- if: type != cron
stage: "Build Verilator"
name: Build Verilator
compiler: gcc
script: echo "Done building Verilator"
# Non-cron build will just run on whatever linux flavor we get
- if: type != cron
stage: test
name: Dist test
compiler: gcc
script: ci/test.sh dist
- if: type != cron
stage: test
name: Vlt test
compiler: gcc
script: ci/test.sh vlt
- if: type != cron
stage: test
name: Vltmt set 0 test
compiler: gcc
script: ci/test.sh vltmt0
- if: type != cron
stage: test
name: Vltmt set 1 test
compiler: gcc
script: ci/test.sh vltmt1
# Cron builds try different OS/compiler combinations
- if: type = cron
stage: "Build Verilator"
name: Build xenial gcc Verilator
os: linux
dist: xenial
compiler: gcc
script: echo "Done building Verilator"
- if: type = cron
stage: test
name: Xenial gcc dist test
os: linux
dist: xenial
compiler: gcc
script: ci/test.sh dist
- if: type = cron
stage: test
name: Xenial gcc vlt test
os: linux
dist: xenial
compiler: gcc
script: ci/test.sh vlt
- if: type = cron
stage: test
name: Xenial gcc vltmt test
os: linux
dist: xenial
compiler: gcc
script: ci/test.sh vltmt
- if: type = cron
stage: "Build Verilator"
name: Build xenial clang Verilator
os: linux
dist: xenial
compiler: clang
script: echo "Done building Verilator"
- if: type = cron
stage: test
name: Xenial clang dist test
os: linux
dist: xenial
compiler: clang
script: ci/test.sh dist
- if: type = cron
stage: test
name: Xenial clang vlt test
os: linux
dist: xenial
compiler: clang
script: ci/test.sh vlt
- if: type = cron
stage: test
name: Xenial clang vltmt test
os: linux
dist: xenial
compiler: clang
script: ci/test.sh vltmt
# - if: type = cron
# stage: "Build Verilator"
# name: Build OSX gcc Verilator
# os: osx
# compiler: gcc
# script: echo "Done building Verilator"
# - if: type = cron
# stage: test
# name: OSX gcc dist test
# os: osx
# compiler: gcc
# script: ci/test.sh dist
# - if: type = cron
# stage: test
# name: OSX gcc vlt test
# os: osx
# compiler: gcc
# script: ci/test.sh vlt
# - if: type = cron
# stage: test
# name: OSX gcc vltmt test
# os: osx
# compiler: gcc
# script: ci/test.sh vltmt
- if: type = cron
stage: "Build Verilator"
name: Build trusty gcc Verilator
os: linux
dist: trusty
compiler: gcc
script: echo "Done building Verilator"
- if: type = cron
stage: test
name: Trusty gcc dist test
os: linux
dist: trusty
compiler: gcc
script: ci/test.sh dist
- if: type = cron
stage: test
name: Trusty gcc vlt test
os: linux
dist: trusty
compiler: gcc
script: ci/test.sh vlt
- if: type = cron
stage: test
os: linux
dist: trusty
name: Trusty gcc vltmt test
compiler: gcc
script: ci/test.sh vltmt
notifications:
email:
if: repo = verilator/verilator
recipients:
- [email protected]
- [email protected]
+1176 -852
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -1,3 +1,4 @@
\.ccache/
\.clang-format
\.clang-tidy
\.git/
@@ -23,6 +24,7 @@
/obj_dir/
/obj_dist/
/obj_iv/
/obj_ms/
/obj_nc/
/obj_opt/
/obj_vcs/
@@ -45,6 +47,8 @@ src/Makefile$
src/Makefile_obj$
include/verilated.mk$
test_regress/.gdbinit$
test_regress/transcript
codecov.yml
config.cache$
config.status$
verilator\.log
@@ -65,4 +69,5 @@ ci/
/csrc/
obj_dir.*
TAGS
gmon.out
.*~
+48 -13
View File
@@ -7,7 +7,7 @@
#
#*****************************************************************************
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# Copyright 2003-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
@@ -89,7 +89,6 @@ datarootdir = @datarootdir@
CFG_WITH_CCWARN = @CFG_WITH_CCWARN@
CFG_WITH_DEFENV = @CFG_WITH_DEFENV@
CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@
CFG_WITH_THREADED = @CFG_WITH_THREADED@
PACKAGE_VERSION = @PACKAGE_VERSION@
#### End of system configuration section. ####
@@ -154,6 +153,7 @@ DISTFILES_INC = $(INFOS) .gitignore \
.*attributes */.*attributes */*/.*attributes \
src/.*ignore src/*.in src/*.cpp src/*.[chly] \
src/astgen src/bisonpre src/*fix src/cppcheck_filtered \
src/config_rev \
src/vlcovgen src/mkinstalldirs \
src/.gdbinit \
src/*.pl src/*.pod \
@@ -171,6 +171,8 @@ DISTFILES_INC = $(INFOS) .gitignore \
test_regress/t/t*/*.v* \
test_regress/t/t*/*/*.sv* \
test_regress/t/t*/*/*.v* \
test_regress/t/t*/*.cpp \
test_regress/t/t*/CMakeLists.txt \
test_regress/t/*.cpp \
test_regress/t/*.h \
test_regress/t/*.dat \
@@ -218,7 +220,7 @@ all_nomsg: verilator_exe $(VL_INST_MAN_FILES)
verilator_exe verilator_bin verilator_bin_dbg verilator_coverage_bin_dbg:
@echo ------------------------------------------------------------
@echo "making verilator in src"
$(MAKE) -C src $(OBJCACHE_JOBS)
$(MAKE) -C src $(OBJCACHE_JOBS) $(CI_MAKE_SRC_TARGET)
.PHONY:msg_test
msg_test: all_nomsg
@@ -336,6 +338,7 @@ installdata:
$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/examples/cmake_tracing_c
$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/examples/cmake_tracing_sc
$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/examples/cmake_protect_lib
$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/examples/xml_py
cd $(srcdir) \
; for p in $(VL_INST_DATA_SRCDIR_FILES) ; do \
$(INSTALL_DATA) $$p $(DESTDIR)$(pkgdatadir)/$$p; \
@@ -370,8 +373,8 @@ uninstall:
-rmdir $(DESTDIR)$(pkgdatadir)/examples/cmake_tracing_c
-rmdir $(DESTDIR)$(pkgdatadir)/examples/cmake_tracing_sc
-rmdir $(DESTDIR)$(pkgdatadir)/examples/cmake_protect_lib
-rmdir $(DESTDIR)$(pkgdatadir)/examples/xml_py
-rmdir $(DESTDIR)$(pkgdatadir)/examples
-rmdir $(DESTDIR)$(pkgdatadir)/cmake
-rmdir $(DESTDIR)$(pkgdatadir)
-rmdir $(DESTDIR)$(pkgconfigdir)
@@ -419,12 +422,16 @@ endif
# Use --xml flag to see the cppcheck code to use for suppression
CPPCHECK_CPP = $(wildcard \
$(srcdir)/examples/*/*.cpp \
$(srcdir)/include/*.cpp \
$(srcdir)/src/*.cpp )
CPPCHECK_H = $(wildcard \
$(srcdir)/include/*.h \
$(srcdir)/src/*.h )
CPPCHECK = src/cppcheck_filtered
CPPCHECK_YL = $(wildcard \
$(srcdir)/src/*.y \
$(srcdir)/src/*.l )
CPPCHECK = src/cppcheck_filtered cppcheck
CPPCHECK_FLAGS = --enable=all --inline-suppr \
--suppress=unusedScopedObject --suppress=cstyleCast --suppress=useInitializationList \
--suppress=nullPointerRedundantCheck
@@ -434,18 +441,19 @@ CPPCHECK_INC = -I$(srcdir)/include -I$(srcdir)/src/obj_dbg -I$(srcdir)/src
cppcheck: $(CPPCHECK_DEP)
%.cppcheck: %.cpp
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $<
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 -DVL_THREADED=1 $(CPPCHECK_INC) $<
CLANGTIDY = clang-tidy
CLANGTIDY_FLAGS = -config=''
CLANGTIDY_FLAGS = -config='' -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables'
CLANGTIDY_DEP = $(subst .h,.h.tidy,$(CPPCHECK_H)) \
$(subst .cpp,.cpp.tidy,$(CPPCHECK_CPP))
CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_THREADED=1 -DVL_CPPCHECK=1
clangtidy: $(CLANGTIDY_DEP)
clang-tidy: $(CLANGTIDY_DEP)
%.cpp.tidy: %.cpp
$(CLANGTIDY) $(CLANGTIDY_FLAGS) $< -- -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) | 2>&1 tee $@
$(CLANGTIDY) $(CLANGTIDY_FLAGS) $< -- $(CLANGTIDY_DEFS) $(CPPCHECK_INC) | 2>&1 tee $@
%.h.tidy: %.h
$(CLANGTIDY) $(CLANGTIDY_FLAGS) $< -- -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) | 2>&1 tee $@
$(CLANGTIDY) $(CLANGTIDY_FLAGS) $< -- $(CLANGTIDY_DEFS) $(CPPCHECK_INC) | 2>&1 tee $@
analyzer-src:
-rm -rf src/obj_dbg
@@ -455,6 +463,36 @@ analyzer-include:
-rm -rf examples/*/obj*
scan-build $(MAKE) -k examples
format: clang-format yapf
CLANGFORMAT = clang-format
CLANGFORMAT_FLAGS = -i
CLANGFORMAT_FILES = $(CPPCHECK_CPP) $(CPPCHECK_H) $(CPPCHECK_YL) test_regress/t/*.c* test_regress/t/*.h
clang-format:
@$(CLANGFORMAT) --version | egrep 10.0 > /dev/null \
|| echo "*** You are not using clang-format 10.0, indents may differ from master's ***"
$(CLANGFORMAT) $(CLANGFORMAT_FLAGS) $(CLANGFORMAT_FILES)
YAPF = yapf3
YAPF_FLAGS = -i
YAPF_FILES = \
examples/xml_py/vl_file_copy \
examples/xml_py/vl_hier_graph \
src/config_rev \
src/cppcheck_filtered \
src/flexfix \
src/vlcovgen \
nodist/code_coverage \
nodist/code_coverage.dat \
nodist/dot_importer \
nodist/fuzzer/actual_fail \
nodist/fuzzer/generate_dictionary \
nodist/install_test \
yapf:
$(YAPF) $(YAPF_FLAGS) $(YAPF_FILES)
ftp: info
install-msg:
@@ -534,9 +572,6 @@ dist-file-list:
@echo $(wildcard $(DISTFILES))
@echo "end-dist-file-list:"; # Scripts look for this
print-cfg-with-threaded:
@echo $(CFG_WITH_THREADED)
######################################################################
# Distributions
+26 -23
View File
@@ -4,8 +4,9 @@
ifdef::env-github[]
image:https://img.shields.io/badge/License-LGPL%20v3-blue.svg[license LGPLv3,link=https://www.gnu.org/licenses/lgpl-3.0]
image:https://img.shields.io/badge/License-Artistic%202.0-0298c3.svg[license Artistic-2.0,link=https://opensource.org/licenses/Artistic-2.0]
image:https://api.codacy.com/project/badge/Grade/48478c986f13400682ffe4a5e0939b3a[Code Quality,link=https://www.codacy.com/gh/verilator/verilator]
image:https://travis-ci.com/verilator/verilator.svg?branch=master[Build Status (Travis CI),link=https://travis-ci.com/verilator/verilator]
image:https://api.codacy.com/project/badge/Grade/fa78caa433c84a4ab9049c43e9debc6f[Code Quality,link=https://www.codacy.com/gh/verilator/verilator]
image:https://codecov.io/gh/verilator/verilator/branch/master/graph/badge.svg[Coverage,link=https://codecov.io/gh/verilator/verilator]
image:https://github.com/verilator/verilator/workflows/build/badge.svg[Build Status (GitHub),link=https://github.com/verilator/verilator/actions?query=workflow%3Abuild]
endif::[]
ifdef::env-github[]
@@ -20,9 +21,9 @@ endif::[]
== Welcome to Verilator
[cols="a,a",indent=0,frame="none"]
[cols="a,a",indent=0,frame="none",grid="rows"]
|===
^.^| *Welcome to Verilator, the fastest free Verilog HDL simulator.*
^.^| *Welcome to Verilator, the fastest Verilog/SystemVerilog simulator.*
+++ <br/> +++ &bullet; Accepts synthesizable Verilog or SystemVerilog
+++ <br/> +++ &bullet; Performs lint code-quality checks
+++ <br/> +++ &bullet; Compiles into multithreaded {cpp}, or SystemC
@@ -56,7 +57,7 @@ endif::[]
== What Verilator Does
Verilator is invoked with parameters similar to GCC or Synopsys's VCS. It
"Verilates" the specified synthesizable Verilog or SystemVerilog code by
"Verilates" the specified Verilog or SystemVerilog code by
reading it, performing lint checks, and optionally inserting assertion
checks and coverage-analysis points. It outputs single- or multi-threaded
.cpp and .h files, the "Verilated" code.
@@ -72,30 +73,30 @@ Verilator may not be the best choice if you are expecting a full featured
replacement for NC-Verilog, VCS or another commercial Verilog simulator, or
if you are looking for a behavioral Verilog simulator e.g. for a quick
class project (we recommend http://iverilog.icarus.com[Icarus Verilog] for
this.) However, if you are looking for a path to migrate synthesizable
Verilog to {cpp} or SystemC, and your team is comfortable writing just a
touch of {cpp} code, Verilator is the tool for you.
this.) However, if you are looking for a path to migrate SystemVerilog to
{cpp} or SystemC, or your team is comfortable writing just a touch of {cpp}
code, Verilator is the tool for you.
== Performance
Verilator does not simply convert Verilog HDL to {cpp} or SystemC. Rather
than only translate, Verilator compiles your code into a much faster
optimized and optionally thread-partitioned model, which is in turn wrapped
inside a {cpp}/SystemC/{cpp}-under-Python module. The results are a compiled Verilog
model that executes even on a single-thread over 10x faster than standalone
SystemC, and on a single thread is about 100 times faster than interpreted
Verilog simulators such as http://iverilog.icarus.com[Icarus
Verilator does not simply convert Verilog HDL to {cpp} or SystemC. Rather,
Verilator compiles your code into a much faster optimized and optionally
thread-partitioned model, which is in turn wrapped inside a
{cpp}/SystemC module. The results are a compiled
Verilog model that executes even on a single-thread over 10x faster than
standalone SystemC, and on a single thread is about 100 times faster than
interpreted Verilog simulators such as http://iverilog.icarus.com[Icarus
Verilog]. Another 2-10x speedup might be gained from multithreading
(yielding 200-1000x total over interpreted simulators).
Verilator has typically similar or better performance versus the commercial
Verilog simulators (Carbon Design Systems Carbonator, Modelsim, Cadence
Incisive/NC-Verilog, Synopsys VCS, VTOC, and Pragmatic CVer/CVC). But,
Verilator is free, so you can spend on computes rather than licenses. Thus
Verilator gives you more cycles/dollar than anything else available.
Verilator has typically similar or better performance versus the
closed-source Verilog simulators (Carbon Design Systems Carbonator,
Modelsim, Cadence Incisive/NC-Verilog, Synopsys VCS, VTOC, and Pragmatic
CVer/CVC). But, Verilator is open-sourced, so you can spend on computes
rather than licenses. Thus Verilator gives you the best cycles/dollar.
For more information on how Verilator stacks up to some of the other
commercial and free Verilog simulators, see the
closed-sourced and open-sourced Verilog simulators, see the
https://www.veripool.org/verilog_sim_benchmarks.html[Verilog Simulator
Benchmarks]. (If you benchmark Verilator, please see the notes in the
https://verilator.org/verilator_doc.pdf[Verilator manual (PDF)], and also
@@ -112,9 +113,11 @@ For more information:
* https://verilator.org/verilator_doc.html[Verilator manual (HTML)],
or https://verilator.org/verilator_doc.pdf[Verilator manual (PDF)]
* https://github.com/verilator/verilator-announce[Subscribe to verilator announcements]
* https://verilator.org/forum[Verilator forum]
* https://verilator.org/issues[Verilator Issues]
* https://verilator.org/issues[Verilator issues]
== Support
@@ -142,7 +145,7 @@ perhaps Icarus may.
== Open License
Verilator is Copyright 2003-2020 by Wilson Snyder. (Report bugs to
Verilator is Copyright 2003-2021 by Wilson Snyder. (Report bugs to
https://verilator.org/issues[Verilator Issues].)
Verilator is free software; you can redistribute it and/or modify it under
+1049 -717
View File
File diff suppressed because it is too large Load Diff
+19 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
######################################################################
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# Copyright 2003-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
@@ -156,6 +156,8 @@ verilator_coverage - Verilator coverage analyzer
verilator_coverage -write merged.dat -read <datafiles>...
verilator_coverage -write-info merged.info -read <datafiles>...
Verilator_coverage processes Verilator coverage reports.
With --anotate, it reads the specified data file and generates annotated
@@ -224,8 +226,20 @@ Displays program version and exits.
=item --write I<filename>
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename. This is useful in scripts to
combine many sequential runs into one master coverage file.
should be written to the given filename in verilator_coverage data format.
This is useful in scripts to combine many sequential runs into one master
coverage file.
=item --write-info I<filename.info>
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename in C<lcov> .info format.
This may be used to use C<lcov> to aggregate or generate reports.
The info format loses data compared to the Verilator coverage data format;
the info will all forms of coverage converted to line style coverage, and
if there are multiple coverage points on a single line, the minimum
coverage across those points will be used to report coverage of the line.
=back
@@ -264,7 +278,7 @@ Specifies a module search directory.
The latest version is available from L<https://verilator.org>.
Copyright 2003-2020 by Wilson Snyder. This program is free software; you
Copyright 2003-2021 by Wilson Snyder. This program is free software; you
can redistribute it and/or modify the Verilator internals under the terms
of either the GNU Lesser General Public License Version 3 or the Perl
Artistic License Version 2.0.
@@ -277,7 +291,7 @@ Wilson Snyder <[email protected]>
=head1 SEE ALSO
C<verilator>
C<verilator>, C<lcov>
L<verilator_coverage --help> which is the source for this document.
+1 -26
View File
@@ -9,22 +9,6 @@ use Pod::Usage;
use strict;
use vars qw($Debug);
#======================================================================
# Old version 1 dump nodes with no dtypep's
our %Ver1_Non_Dtyped = map {$_ => 1} qw(
ACTIVE ALWAYS ALWAYSPOST ALWAYSPUBLIC ATTROF BEGIN BREAK CASE CASEITEM
CCALL CELL CELLINLINE CFILE CFUNC CHANGEDET CLOCKING COMMENT CONTINUE
COVERDECL COVERINC COVERTOGGLE CRETURN CSTMT DEFPARAM DISABLE DISPLAY DOT
DPIEXPORT FCLOSE FFLUSH FINAL FINISH FOPEN GENCASE GENERATE GENFOR GENIF
IF IMPLICIT INITARRAY INITIAL JUMPGO JUMPLABEL MODULE NETLIST
NOTFOUNDMODULE PACKAGE PACKAGEIMPORT PARSEREF PIN PORT PRAGMA PRIMITIVE
PSLASSERT PSLCOVER PSLDEFCLOCK PULL RANGE READMEM REPEAT RETURN SCCTOR
SCDTOR SCHDR SCIMP SCIMPHDR SCINT SCOPE SELBIT SELEXTRACT SELMINUS
SELPLUS SENGATE SENITEM SENTREE SFORMAT SFORMATF STOP SYSIGNORE SYSTEMT
TASK TASKREF TEXT TOPSCOPE TYPEDEFFWD TYPETABLE UCSTMT UDPTABLE
UDPTABLELINE UNTILSTABLE VASSERT WHILE );
#======================================================================
# main
@@ -133,8 +117,6 @@ sub filter {
$line =~ s/{[a-z]*\d+}/{}/g if !$Opt_Lineno;
if ($verCvt) {
next if $line =~ /^ NETLIST/;
$line =~ s!\@dt=0x\(G?/?([^)]+)\)!$1!g; # NEW: @dt -> OLD: non @dt format
# # Below Ver1_Non_Dtyped may replace above further
if ($line =~ /: ([A-Z]+) /) {
my $type = $1;
next if $type =~ 'DTYPE';
@@ -147,14 +129,7 @@ sub filter {
}
next;
}
if ($Ver1_Non_Dtyped{$type}) {
$line =~ s! w[0-9]+!!g;
}
}
$line =~ s!\@dt=0$!NoW!g; # NEW: dt=null -> common format
$line =~ s!\@dt=0 !NoW !g; # NEW: dt=null -> common format
$line =~ s! s?w0$! NoW!g; # OLD: no width -> common format
$line =~ s! s?w0 ! NoW !g; # OLD: no width -> common format
}
print $f2 $line;
}
@@ -233,7 +208,7 @@ Do not show differences in line numbering.
The latest version is available from L<https://verilator.org>.
Copyright 2005-2020 by Wilson Snyder. This program is free software; you
Copyright 2005-2021 by Wilson Snyder. This program is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License
Version 2.0.
+89 -10
View File
@@ -60,6 +60,7 @@ sub process {
my $filename = shift;
read_data($filename);
read_cpuinfo();
report();
}
@@ -70,7 +71,7 @@ sub read_data {
%Global = (rdtsc_cycle_time => 0);
my $fh = IO::File->new ($filename) or die "%Error: $! $filename,";
my $fh = IO::File->new("<$filename") or die "%Error: $! $filename,";
while (my $line = $fh->getline) {
if ($line =~ m/VLPROF mtask\s(\d+)\sstart\s(\d+)\send\s(\d+)\selapsed\s(\d+)\spredict_time\s(\d+)\scpu\s(\d+)\son thread (\d+)/) {
my $mtask = $1;
@@ -113,6 +114,27 @@ sub read_data {
}
}
sub read_cpuinfo {
my $filename = "/proc/cpuinfo";
my $fh = IO::File->new("<$filename") or return;
my $cpu;
while (my $line = $fh->getline) {
chomp $line;
if ($line =~ m/^processor\s*:\s*(\d+)\s*$/) {
$cpu = $1;
}
if ($cpu && $line =~ m/^([a-z_ ]+)\s*:\s*(.*)$/) {
my ($term, $value) = ($1, $2);
$term =~ s/\s+$//;
$term =~ s/\s+/_/;
$value =~ s/\s+$//;
$Global{cpuinfo}{$cpu}{$term} = $value;
}
}
}
#######################################################################
sub report {
print "Verilator Gantt report\n";
@@ -156,14 +178,15 @@ sub report {
print "\nAnalysis:\n";
printf " Total threads = %d\n", $nthreads;
printf " Total mtasks = %d\n", scalar(keys %Mtasks);
printf " Total cpus used = %d\n", scalar(keys %{$Global{cpus}});
my $ncpus = scalar(keys %{$Global{cpus}});
printf " Total cpus used = %d\n", $ncpus;
printf " Total yields = %d\n", $Global{stats}{yields};
printf " Total eval time = %d rdtsc ticks\n", $Global{last_end};
printf " Longest mtask time = %d rdtsc ticks\n", $long_mtask_time;
printf " All-thread mtask time = %d rdtsc ticks\n", $mt_mtask_time;
my $long_efficiency = $long_mtask_time/($Global{last_end});
my $long_efficiency = $long_mtask_time/($Global{last_end} || 1);
printf " Longest-thread efficiency = %0.1f%%\n", $long_efficiency*100;
my $mt_efficiency = $mt_mtask_time/($Global{last_end}*$nthreads);
my $mt_efficiency = $mt_mtask_time/($Global{last_end}*$nthreads || 1);
printf " All-thread efficiency = %0.1f%%\n", $mt_efficiency*100;
printf " All-thread speedup = %0.1f\n", $mt_efficiency*$nthreads;
if ($Global{rdtsc_cycle_time} > 0) {
@@ -197,17 +220,72 @@ sub report {
}
print "\nStatistics:\n";
print " min log(p2e) = $min_p2e from mtask $min_mtask (predict $Mtasks{$min_mtask}{predict}, elapsed $Mtasks{$min_mtask}{elapsed})\n";
print " max log(p2e) = $max_p2e from mtask $max_mtask (predict $Mtasks{$max_mtask}{predict}, elapsed $Mtasks{$max_mtask}{elapsed})\n";
printf " min log(p2e) = %0.3f", $min_p2e;
print " from mtask $min_mtask (predict $Mtasks{$min_mtask}{predict},";
print " elapsed $Mtasks{$min_mtask}{elapsed})\n";
printf " max log(p2e) = %0.3f", $max_p2e;
print " from mtask $max_mtask (predict $Mtasks{$max_mtask}{predict},";
print " elapsed $Mtasks{$max_mtask}{elapsed})\n";
my $stddev = stddev(\@p2e_ratios);
my $mean = mean(\@p2e_ratios);
print " mean = " . ($mean) . "\n";
print " stddev = " . ($stddev) . "\n";
print " e ^ stddev = " . exp($stddev). "\n";
printf " mean = %0.3f\n", $mean;
printf " stddev = %0.3f\n", $stddev;
printf " e ^ stddev = %0.3f\n", exp($stddev);
report_cpus();
if ($nthreads > $ncpus) {
print "\n";
print "%Warning: There were fewer CPUs ($ncpus) then threads ($nthreads).\n";
print " : See docs on use of numactl.\n";
} else {
if ($Global{cpu_socket_cores_warning}) {
print "\n";
print "%Warning: Multiple threads scheduled on same hyperthreaded core.\n";
print " : See docs on use of numactl.\n";
}
if ($Global{cpu_sockets_warning}) {
print "\n";
print "%Warning: Threads scheduled on multiple sockets.\n";
print " : See docs on use of numactl.\n";
}
}
print "\n";
}
sub report_cpus {
print "\nCPUs:\n";
# Test - show all cores
# for (my $i=0; $i<73; ++$i) { $Global{cpus}{$i} ||= {cpu_time => 0}; }
$Global{cpu_sockets} ||= {};
$Global{cpu_socket_cores} ||= {};
foreach my $cpu (sort {$a <=> $b} keys %{$Global{cpus}}) {
printf " cpu %d: ", $cpu;
printf "cpu_time=%d", $Global{cpus}{$cpu}{cpu_time};
my $socket = $Global{cpuinfo}{$cpu}{physical_id};
$Global{cpu_sockets}{$socket}++ if defined $socket;
printf " socket=%d", $socket if defined $socket;
my $core = $Global{cpuinfo}{$cpu}{core_id};
$Global{cpu_socket_cores}{$socket."__".$core}++ if defined $socket && defined $core;
printf " core=%d", $core if defined $core;
my $model = $Global{cpuinfo}{$cpu}{model_name};
printf " %s", $model if defined $model;
print "\n";
}
$Global{cpu_sockets_warning} = 1
if (scalar keys %{$Global{cpu_sockets}} > 1);
foreach my $scn (values %{$Global{cpu_socket_cores}}) {
$Global{cpu_socket_cores_warning} = 1 if $scn > 1;
}
}
sub report_graph {
my $time_per = $Opt_Time_Per_Char;
if ($time_per == 0) {
@@ -219,6 +297,7 @@ sub report_graph {
}
# One more step so we can fit more labels
$time_per = int($time_per/2);
$time_per ||= 1;
}
my ($graph, $conflicts) = _make_graph($time_per);
@@ -538,7 +617,7 @@ verilator_gantt.vcd.
The latest version is available from L<https://verilator.org>.
Copyright 2018-2020 by Wilson Snyder. This program is free software; you
Copyright 2018-2021 by Wilson Snyder. This program is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License
Version 2.0.
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
# DESCRIPTION: Print include statements for each ARGV
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# Copyright 2003-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
+1 -1
View File
@@ -228,7 +228,7 @@ Displays this message and program version and exits.
The latest version is available from L<https://verilator.org>.
Copyright 2007-2020 by Wilson Snyder. This program is free software; you
Copyright 2007-2021 by Wilson Snyder. This program is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License
Version 2.0.
-19
View File
@@ -1,19 +0,0 @@
#!/bin/bash
# DESCRIPTION: Verilator: Build script for vcddiff
#
# Copyright 2019 by Todd Strader. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
set -e
# NB: it would be better to add this via a PPA
TMP_DIR=$(mktemp -d)
git -C "${TMP_DIR}" clone https://github.com/veripool/vcddiff
VCDDIFF_DIR=${TMP_DIR}/vcddiff
git -C "${VCDDIFF_DIR}" checkout 5112f88b7ba8818dce9dfb72619e64a1fc19542c
make -C "${VCDDIFF_DIR}"
sudo cp "${VCDDIFF_DIR}/vcddiff" /usr/local/bin
-65
View File
@@ -1,65 +0,0 @@
#!/bin/bash
# DESCRIPTION: Verilator: Travis CI build script
#
# Copyright 2019 by Todd Strader. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
#
# This script builds and caches the Verilator binaries for Travis CI
# (and possibly other CI platforms). The Verilator CI system uses this
# script, but other CI systems that depend on Verilator may also use
# the script.
# see: https://github.com/verilator/verilator_ext_tests/blob/master/.travis.yml
# To use this script, either checkout Verilator as part of the CI build
# process or add Verilator as a Git submodule. Verilator tarballs can
# not be used as the script relies on Git revisions for caching.
set -e
if [ -z "${VERILATOR_NUM_JOBS}" ]; then
VERILATOR_NUM_JOBS=$(nproc)
fi
# Caching would be simpler if we installed without VERILATOR_ROOT, but
# it's needed for driver.pl outside of the repo
if [ -z "${VERILATOR_ROOT}" ]; then
echo "VERILATOR_ROOT not set"
exit -1
fi
if [ -z "${VERILATOR_CACHE}" ]; then
echo "VERILATOR_CACHE not set"
exit -1
fi
VERILATOR_REV=$(cd "${VERILATOR_ROOT}" && git rev-parse HEAD)
echo "Found Verilator rev ${VERILATOR_REV}"
CACHED_REV_FILE=${VERILATOR_CACHE}/.rev.txt
if [[ ! -f "${CACHED_REV_FILE}" || \
$(< "${CACHED_REV_FILE}") != "${VERILATOR_REV}" ]]; then
echo "Building Verilator"
# Unsure why Travis monkies with the capitalization of the stage name, but it does
if [[ -n ${TRAVIS_BUILD_STAGE_NAME} && \
${TRAVIS_BUILD_STAGE_NAME} != "Build verilator" ]]; then
echo "WARNING: Building Verilator in Travis build stage other than \"Build verilator\": ${TRAVIS_BUILD_STAGE_NAME}"
fi
cd "${VERILATOR_ROOT}"
autoconf && ./configure ${VERILATOR_CONFIG_FLAGS} && make -j ${VERILATOR_NUM_JOBS}
# Copy the Verilator build artifacts
mkdir -p "${VERILATOR_CACHE}"
rm -rf ${VERILATOR_CACHE}/*
cp bin/*bin* "${VERILATOR_CACHE}"
# Remember the Git revision
echo "${VERILATOR_REV}" > "${CACHED_REV_FILE}"
else
echo "Using cached Verilator"
cd "${VERILATOR_ROOT}"
# Create include/verilated_config.h and maybe other things
autoconf && ./configure ${VERILATOR_CONFIG_FLAGS}
cp ${VERILATOR_CACHE}/* bin
fi
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# DESCRIPTION: Verilator: CI ccache maintenance
#
# Copyright 2020 by Geza Lore. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
################################################################################
# This script is run in 'before_script', once ccache has been set up.
################################################################################
set -e
set -x
# Show version
ccache --version
# Flush ccache if requested in commit message
COMMIT="${CI_PULL_REQUEST_SHA:-$CI_COMMIT}"
if git log --format=%B -n 1 "$COMMIT" | grep -q -i '\[CI\s\+ccache\s\+clear\]'; then
echo "Flushing ccache due to commit message"
ccache -C
fi
# Dump stats, then zero stats
ccache -s -z
+111
View File
@@ -0,0 +1,111 @@
#!/usr/bin/env bash
# DESCRIPTION: Verilator: CI dependency install script
#
# Copyright 2020 by Geza Lore. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
################################################################################
# This script runs in the 'install' phase of all jobs, in all stages. We try to
# minimize the time spent in this by selectively installing only the components
# required by the particular build stage.
################################################################################
set -e
set -x
cd $(dirname "$0")/..
fatal() {
echo "ERROR: $(basename "$0"): $1" >&2; exit 1;
}
if [ "$CI_OS_NAME" = "linux" ]; then
MAKE=make
elif [ "$CI_OS_NAME" = "osx" ]; then
MAKE=make
elif [ "$CI_OS_NAME" = "freebsd" ]; then
MAKE=gmake
else
fatal "Unknown os: '$CI_OS_NAME'"
fi
install-vcddiff() {
TMP_DIR="$(mktemp -d)"
git clone https://github.com/veripool/vcddiff "$TMP_DIR"
git -C "${TMP_DIR}" checkout 5112f88b7ba8818dce9dfb72619e64a1fc19542c
"$MAKE" -C "${TMP_DIR}"
sudo cp "${TMP_DIR}/vcddiff" /usr/local/bin
}
if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then
##############################################################################
# Dependencies of jobs in the 'build' stage, i.e.: packages required to
# build Verilator
if [ "$CI_OS_NAME" = "linux" ]; then
sudo apt-get update
sudo apt-get install libfl-dev libgoogle-perftools-dev ccache
if [ "$CI_RUNS_ON" = "ubuntu-20.04" ]; then
sudo apt-get install libsystemc libsystemc-dev
fi
if [ "$COVERAGE" = 1 ]; then
yes yes | sudo cpan -fi Parallel::Forker
fi
if [ "$M32" = 1 ]; then
sudo apt-get install gcc-multilib g++-multilib
fi
elif [ "$CI_OS_NAME" = "osx" ]; then
brew update
brew install ccache perl gperftools
elif [ "$CI_OS_NAME" = "freebsd" ]; then
sudo pkg install -y autoconf bison ccache gmake perl5
else
fatal "Unknown os: '$CI_OS_NAME'"
fi
if [ -n "$CCACHE_DIR" ]; then
mkdir -p "$CCACHE_DIR" && ./ci/ci-ccache-maint.bash
fi
elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
##############################################################################
# Dependencies of jobs in the 'test' stage, i.e.: packages required to
# run the tests
if [ "$CI_OS_NAME" = "linux" ]; then
sudo apt-get update
# libfl-dev needed for internal coverage's test runs
sudo apt-get install gdb gtkwave lcov libfl-dev ccache
if [ "$CI_RUNS_ON" = "ubuntu-20.04" ]; then
sudo apt-get install libsystemc-dev
fi
if [ "$M32" = 1 ]; then
sudo apt-get install lib32z1-dev gcc-multilib g++-multilib
fi
elif [ "$CI_OS_NAME" = "osx" ]; then
brew update
# brew cask install gtkwave # fst2vcd hangs at launch, so don't bother
brew install ccache perl
elif [ "$CI_OS_NAME" = "freebsd" ]; then
# fst2vcd fails with "Could not open '<input file>', exiting."
sudo pkg install -y ccache gmake perl5 python3
else
fatal "Unknown os: '$CI_OS_NAME'"
fi
# Common installs
if [ "$CI_RUNS_ON" != "ubuntu-14.04" ]; then
CI_CPAN_REPO=https://cpan.org
fi
yes yes | sudo cpan -M $CI_CPAN_REPO -fi Parallel::Forker
install-vcddiff
autoconf
./configure --enable-longtests --enable-ccwarn
else
##############################################################################
# Unknown build stage
fatal "Unknown build stage: '$CI_BUILD_STAGE_NAME'"
fi
+141
View File
@@ -0,0 +1,141 @@
#!/usr/bin/env bash
# DESCRIPTION: Verilator: CI main job script
#
# Copyright 2020 by Geza Lore. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
################################################################################
# This is the main script executed in the 'script' phase by all jobs. We use a
# single script to keep the CI setting simple. We pass job parameters via
# environment variables using 'env' keys.
################################################################################
set -e
set -x
fatal() {
echo "ERROR: $(basename "$0"): $1" >&2; exit 1;
}
if [ "$CI_OS_NAME" = "linux" ]; then
export MAKE=make
NPROC=$(nproc)
elif [ "$CI_OS_NAME" = "osx" ]; then
export MAKE=make
NPROC=$(sysctl -n hw.logicalcpu)
elif [ "$CI_OS_NAME" = "freebsd" ]; then
export MAKE=gmake
NPROC=$(sysctl -n hw.ncpu)
else
fatal "Unknown os: '$CI_OS_NAME'"
fi
if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then
##############################################################################
# Build verilator
if [ "$COVERAGE" != 1 ]; then
autoconf
./configure --enable-longtests --enable-ccwarn
"$MAKE" -j "$NPROC" -k
if [ "$CI_OS_NAME" = "osx" ]; then
file bin/verilator_bin
file bin/verilator_bin_dbg
md5 bin/verilator_bin
md5 bin/verilator_bin_dbg
stat bin/verilator_bin
stat bin/verilator_bin_dbg
fi
else
nodist/code_coverage --stages 1-2
fi
elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
##############################################################################
# Run tests
export VERILATOR_TEST_NO_CONTRIBUTORS=1 # Separate workflow check
if [ "$CI_OS_NAME" = "osx" ]; then
export VERILATOR_TEST_NO_GDB=1 # Pain to get GDB to work on OS X
export VERILATOR_TEST_NO_GPROF=1 # Apple Clang has no -pg
# export PATH="/Applications/gtkwave.app/Contents/Resources/bin:$PATH" # fst2vcd
file bin/verilator_bin
file bin/verilator_bin_dbg
md5 bin/verilator_bin
md5 bin/verilator_bin_dbg
stat bin/verilator_bin
stat bin/verilator_bin_dbg
# For some reason, the dbg exe is corrupted by this point ('file' reports
# it as data rather than a Mach-O). Unclear if this is an OS X issue or
# CI's. Remove the file and re-link...
rm bin/verilator_bin_dbg
"$MAKE" -j "$NPROC" -k
elif [ "$CI_OS_NAME" = "freebsd" ]; then
export VERILATOR_TEST_NO_GDB=1 # Disable for now, ideally should run
export VERILATOR_TEST_NO_GPROF=1 # gprof is a bit different on FreeBSD, disable
fi
# Run sanitize on Ubuntu 20.04 only
[ "$CI_RUNS_ON" = 'ubuntu-20.04' ] && sanitize='--sanitize' || sanitize=''
# Run the specified test
case $TESTS in
dist-vlt-0)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/2
;;
dist-vlt-1)
"$MAKE" -C test_regress SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=1/2
;;
vltmt-0)
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
;;
vltmt-1)
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
;;
coverage-all)
nodist/code_coverage --stages 3-
;;
coverage-dist)
nodist/code_coverage --stages 3- --scenarios=--dist
;;
coverage-vlt-0)
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=0/4
;;
coverage-vlt-1)
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=1/4
;;
coverage-vlt-2)
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=2/4
;;
coverage-vlt-3)
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=3/4
;;
coverage-vltmt-0)
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=0/4
;;
coverage-vltmt-1)
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=1/4
;;
coverage-vltmt-2)
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=2/4
;;
coverage-vltmt-3)
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=3/4
;;
*)
fatal "Unknown test: $TESTS"
;;
esac
# Upload coverage data to codecov.io
if [[ $TESTS == coverage-* ]]; then
bash <(curl -s https://codecov.io/bash) -f nodist/obj_dir/coverage/app_total.info
fi
else
##############################################################################
# Unknown build stage
fatal "Unknown build stage: '$CI_BUILD_STAGE_NAME'"
fi
+28 -30
View File
@@ -6,45 +6,41 @@
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
FROM ubuntu:18.04
FROM ubuntu:20.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends -y \
autoconf=2.69-11 \
bc=1.07.1-2 \
bison=2:3.0.4.dfsg-1build1 \
build-essential=12.4ubuntu1 \
ca-certificates=20180409 \
cmake=3.10.2-1ubuntu2.18.04.1 \
flex=2.6.4-6 \
gdb=8.1-0ubuntu3.2 \
gcc-6=6.5.0-2ubuntu1~18.04 \
gcc-5=5.5.0-12ubuntu1 \
gcc-4.8=4.8.5-4ubuntu8 \
git=1:2.17.1-1ubuntu0.5 \
gtkwave=3.3.86-1 \
g++-6=6.5.0-2ubuntu1~18.04 \
g++-5=5.5.0-12ubuntu1 \
g++-4.8=4.8.5-4ubuntu8 \
libfl2=2.6.4-6 \
libfl-dev=2.6.4-6 \
numactl=2.0.11-2.1ubuntu0.1 \
perl=5.26.1-6ubuntu0.3 \
python3=3.6.7-1~18.04 \
wget=1.19.4-1ubuntu2.2 \
zlibc=0.9k-4.3 \
zlib1g=1:1.2.11.dfsg-0ubuntu2 \
zlib1g-dev=1:1.2.11.dfsg-0ubuntu2 \
autoconf \
bc \
bison \
build-essential \
ca-certificates \
ccache \
clang \
cmake \
flex \
gdb \
git \
gtkwave \
libfl2 \
libfl-dev \
libgoogle-perftools-dev \
libsystemc \
libsystemc-dev \
numactl \
perl \
python3 \
wget \
zlibc \
zlib1g \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
COPY build-systemc.sh /tmp/
RUN ./build-systemc.sh
RUN cpan install -fi Unix::Processors Parallel::Forker Bit::Vector
RUN cpan install -fi Parallel::Forker
RUN git clone https://github.com/veripool/vcddiff.git && \
make -C vcddiff && \
@@ -55,4 +51,6 @@ COPY build.sh /tmp/build.sh
ENV VERILATOR_AUTHOR_SITE=1
WORKDIR /work
ENTRYPOINT [ "/tmp/build.sh" ]
+3 -3
View File
@@ -5,7 +5,7 @@ build. It uses the following parameters:
* Source repository (default: https://github.com/verilator/verilator)
* Source revision (default: master)
* GCC version (4.8.5, 5.5.0, 6.5.0, 7.4.0, default: 7.4.0)
* Compiler (GCC 9.3.0, clang 10.0.0, default: 9.3.0)
The container is published as `verilator/verilator-buildenv` on
https://hub.docker.com/repository/docker/verilator/verilator-buildenv[docker hub].
@@ -20,13 +20,13 @@ To also run tests:
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=clang-10 -e CXX=clang++-10 verilator/verilator-buildenv test
The tests that involve gdb are not working due to security restrictions.
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 -e CC=clang-10 -e CXX=clang++-10 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined verilator/verilator-buildenv test
....
Rather then building using a remote git repository you may prefer to use a
-30
View File
@@ -1,30 +0,0 @@
#!/bin/bash -e
# DESCRIPTION: Build SystemC in Ubuntu 18.04 with different g++/gcc
#
# Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
build_variant () {
version=$($1 --version | grep gcc | awk '{print $4}')
mkdir "/usr/local/systemc-2.3.3-gcc$version"
mkdir build
cd build
../configure --prefix="/usr/local/systemc-2.3.3-gcc$version" CC="$1" CXX="$2" LD="$2"
make -j
make install
cd ..
rm -r build
}
wget https://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.3.tar.gz
tar -xzf systemc-2.3.3.tar.gz
cd systemc-2.3.3
build_variant gcc g++
build_variant gcc-6 g++-6
build_variant gcc-5 g++-5
build_variant gcc-4.8 g++-4.8
cd ..
rm -r systemc-2.3.3*
-6
View File
@@ -12,12 +12,6 @@
: "${CC:=gcc}"
: "${CXX:=g++}"
GCCVERSION=$(${CC} --version | grep gcc | awk '{print $4}')
export SYSTEMC_INCLUDE="/usr/local/systemc-2.3.3-gcc${GCCVERSION}/include"
export SYSTEMC_LIBDIR="/usr/local/systemc-2.3.3-gcc${GCCVERSION}/lib-linux64"
export LD_LIBRARY_PATH=${SYSTEMC_LIBDIR}
SRCS=$PWD/verilator
git clone "$REPO" "$SRCS"
+14 -11
View File
@@ -6,20 +6,23 @@
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
FROM ubuntu:18.04
FROM ubuntu:20.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
&& apt-get install --no-install-recommends -y \
autoconf=2.69-11 \
bc=1.07.1-2 \
bison=2:3.0.4.dfsg-1build1 \
build-essential=12.4ubuntu1 \
ca-certificates=20180409 \
flex=2.6.4-6 \
git=1:2.17.1-1ubuntu0.5 \
libfl-dev=2.6.4-6 \
perl=5.26.1-6ubuntu0.3 \
python3=3.6.7-1~18.04 \
autoconf \
bc \
bison \
build-essential \
ca-certificates \
ccache \
flex \
git \
libfl-dev \
libgoogle-perftools-dev \
perl \
python3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
+1 -1
View File
@@ -27,5 +27,5 @@ if [ -e ${obj_dir} ]; then
cp -r /usr/local/share/verilator/bin ${obj_dir}/vlt
cp -r /usr/local/share/verilator/include ${obj_dir}/vlt
# Point Makefile to that folder
perl -i -pe 's/VERILATOR_ROOT = \/usr\/local\/share\/verilator/VERILATOR_ROOT = vlt/g' ${obj_dir}/*.mk
sed -i 's/VERILATOR_ROOT = \/usr\/local\/share\/verilator/VERILATOR_ROOT = vlt/g' ${obj_dir}/*.mk
fi
-34
View File
@@ -1,34 +0,0 @@
#!/bin/bash
# DESCRIPTION: Verilator: Travis CI test script
#
# Copyright 2019 by Todd Strader. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
set -e
export DRIVER_FLAGS='-j 0 --quiet --rerun'
case $1 in
dist)
make -C test_regress SCENARIOS=--dist
;;
vlt)
make -C test_regress SCENARIOS=--vlt
;;
vltmt)
make -C test_regress SCENARIOS=--vltmt
;;
vltmt0)
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
;;
vltmt1)
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
;;
*)
echo "Usage: test.sh (dist|vlt|vltmt)"
exit -1
;;
esac
+38
View File
@@ -0,0 +1,38 @@
# DESCRIPTION: codecov.io config
#
# Copyright 2020-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
####################
# Validate:
# curl --data-binary @codecov.yml https://codecov.io/validate
codecov:
require_ci_to_pass: no
coverage:
precision: 2
round: down
range: "50...100"
ignore:
- "ci"
- "docs"
- "examples"
- "include/gtkwave"
- "include/vltstd"
- "test_regress"
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: yes
+73 -44
View File
@@ -1,22 +1,26 @@
# DESCRIPTION: Process this file with autoconf to produce a configure script.
#
# Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you
# Copyright 2003-2021 by Wilson Snyder. Verilator is free software; you
# can redistribute it and/or modify it under the terms of either the GNU Lesser
# General Public License Version 3 or the Perl Artistic License Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
#AC_INIT([Verilator],[#.### YYYY-MM-DD])
#AC_INIT([Verilator],[#.### devel])
AC_INIT([Verilator],[4.032 2020-04-04],
AC_INIT([Verilator],[4.108 2021-01-10],
[https://verilator.org],
[verilator],[https://verilator.org])
# When releasing, also update header of Changes file
# and commit using "devel release" or "Version bump" message
# Then 'make maintainer-dist'
AC_CONFIG_HEADER(src/config_build.h)
AC_CONFIG_FILES(Makefile docs/Makefile src/Makefile src/Makefile_obj include/verilated.mk include/verilated_config.h verilator.pc verilator-config.cmake verilator-config-version.cmake)
# Version
AC_MSG_RESULT([configuring for $PACKAGE_STRING])
PACKAGE_VERSION_NUMBER=`AS_ECHO("$PACKAGE_VERSION") | sed 's/ .*//g'`
AC_SUBST(PACKAGE_VERSION_NUMBER)
# Ignore automake flags passed by Ubuntu builds
AC_ARG_ENABLE([dependency-tracking],
@@ -109,27 +113,11 @@ AC_ARG_ENABLE([longtests],
AC_SUBST(CFG_WITH_LONGTESTS)
AC_MSG_RESULT($CFG_WITH_LONGTESTS)
# CFG_WITH_PREC11
AC_MSG_CHECKING(whether allow pre-C++11)
AC_ARG_ENABLE([prec11],
[AS_HELP_STRING([--enable-prec11],
[enable pre-C++11 compilers for Verilator binary
and Verilated makefiles])],
[case "${enableval}" in
yes) CFG_WITH_PREC11=yes ;;
no) CFG_WITH_PREC11=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-prec11]) ;;
esac],
[CFG_WITH_PREC11=no;]
)
AC_SUBST(CFG_WITH_PREC11)
AC_MSG_RESULT($CFG_WITH_PREC11)
# Compiler flags
CFLAGS+=" -I${includedir}"
CPPFLAGS+=" -I${includedir}"
CXXFLAGS+=" -I${includedir}"
LDFLAGS+=" -L${libdir}"
# Compiler flags (ensure they are not empty to avoid configure defaults)
CFLAGS+=" "
CPPFLAGS+=" "
CXXFLAGS+=" "
LDFLAGS+=" "
# Checks for programs.
AC_PROG_CC
@@ -150,14 +138,31 @@ AC_PATH_PROG(PERL,perl)
if test "x$PERL" = "x" ; then
AC_MSG_ERROR([Cannot find "perl" in your PATH, please install it])
fi
AC_PATH_PROG(PYTHON3,python3)
if test "x$PYTHON3" = "x" ; then
AC_MSG_ERROR([Cannot find "python3" in your PATH, please install it])
fi
AC_PATH_PROG(LEX,flex)
if test "x$LEX" = "x" ; then
AC_MSG_ERROR([Cannot find "flex" in your PATH, please install it])
fi
flex_version=$($LEX --version | head -1)
AC_MSG_RESULT([$LEX --version = $flex_version])
AC_PATH_PROG(YACC,bison)
if test "x$YACC" = "x" ; then
AC_MSG_ERROR([Cannot find "bison" in your PATH, please install it])
fi
bison_version=$($YACC --version | head -1)
AC_MSG_RESULT([$YACC --version = $bison_version])
AC_CHECK_PROG(OBJCACHE,ccache,ccache)
if test "x$OBJCACHE" != "x" ; then
objcache_version=$($OBJCACHE --version | head -1)
AC_MSG_RESULT([objcache is $OBJCACHE --version = $objcache_version])
fi
# Checks for libraries.
@@ -328,6 +333,7 @@ m4_foreach([cflag],[
[-mno-cet],
[-Qunused-arguments],
[-Wno-bool-operation],
[-Wno-tautological-bitwise-compare],
[-Wno-parentheses-equality],
[-Wno-sign-compare],
[-Wno-uninitialized],
@@ -393,12 +399,17 @@ _MY_LDLIBS_CHECK_IFELSE(
fi])
AC_SUBST(CFG_LIBS)
# Set CFG_WITH_THREADED if can support threading
AC_MSG_CHECKING(whether $CXX supports Verilated threads)
ACO_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_STD_NEWEST $CFG_CXXFLAGS_NO_UNUSED"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <thread>], [[ ]])],
# Need C++11 at least
#Alternative: AX_CXX_COMPILE_STDCXX([11])
AC_DEFUN([_MY_CXX_CHECK_CXX_VER],
[# _MY_CXX_CHECK_CXX_VER(flag) -- Check if compiler runs C++11
# Set $_my_result
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <thread>
#if (__cplusplus < 201103L)
# error "Too old"
#endif
], [[ ]])],
[_my_result=yes
if test -s conftest.err; then
if grep -e "$1" conftest.err >/dev/null; then
@@ -406,24 +417,24 @@ AC_LINK_IFELSE(
fi
fi],
[_my_result=no])
CFG_WITH_THREADED=$_my_result
AC_SUBST(CFG_WITH_THREADED)
AC_MSG_RESULT($CFG_WITH_THREADED)
])
# Check compiler flag
if test "$CFG_WITH_THREADED" = "no" ; then
if test "$CFG_WITH_PREC11" = "no" ; then
AC_MSG_NOTICE([[]])
AC_MSG_ERROR([[the $CXX compiler appears to not support C++11.
AC_MSG_CHECKING(whether $CXX supports C++11)
_MY_CXX_CHECK_CXX_VER()
AC_MSG_RESULT($_my_result)
if test "$_my_result" = "no" ; then
CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_STD_NEWEST"
CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE $CFG_CXXFLAGS_STD_NEWEST"
AC_MSG_CHECKING(whether $CXX supports C++11 with $CFG_CXXFLAGS_STD_NEWEST)
_MY_CXX_CHECK_CXX_VER()
AC_MSG_RESULT($_my_result)
fi
if test "$_my_result" = "no" ; then
AC_MSG_NOTICE([[]])
AC_MSG_ERROR([[the $CXX compiler appears to not support C++11.
Verilator plans to require a C++11 or newer compiler in a future release,
unless sufficient people report problems. Therefore, if you do not have a
C++11 compiler, please post a message to
https://www.veripool.org/boards/3/topics/2580-Verilator-Requiring-C-11-compiler
indicating your OS and when you think C++11 might be ok, and then rerun
configure with the --enable-prec11 argument. Thanks.]])
Verilator requires a C++11 or newer compiler.]])
fi
fi
# Checks for library functions.
@@ -431,6 +442,24 @@ AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec],
[AC_DEFINE([HAVE_STAT_NSEC],[1],[Defined if struct stat has st_mtim.tv_nsec])],
[], [#include <sys/stat.h>])
# HAVE_SYSTEMC
# - If found the default search path has it, so support is always enabled.
# - If not found or not system-wide, user can set SYSTEMC_INCLUDE.
# AC_CHECK_HEADERS seems to not locate on Travis-CI but include does work.
AC_MSG_CHECKING([whether SystemC is found (in system path)])
ACO_SAVE_LIBS="$LIBS"
LIBS="$LIBS -lsystemc"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <systemc.h>
extern "C" int sc_main(int argc, char* argv[]) {}
]],[[sc_version()]])],
[_my_result=yes
AC_DEFINE([HAVE_SYSTEMC],[1],[Defined if have SystemC library])],
[_my_result=no])
AC_MSG_RESULT($_my_result)
LIBS="$ACO_SAVE_LIBS"
AC_SUBST(HAVE_SYSTEMC)
# Checks for system services
# Other install directories
+2 -2
View File
@@ -27,8 +27,8 @@ contributions flow more efficiently.
* You may attach a patch to the issue, or (preferred) may request a GitHub
pull request.
** Verilator uses Travis CI to provide continuous integration. You may
want to setup Travis CI on your GitHub branch to ensure your changes
** Verilator uses GitHub Actions to provide continuous integration. You may
want to enable Actions on your GitHub branch to ensure your changes
keep the tests passing. See link:internals.adoc[docs/internals].
* Your source-code contributions must be certified as open source, under
+46 -4
View File
@@ -1,44 +1,86 @@
The contributors listed below have certified their Verilator contributions
under the Developer Certificate of Origin
(https://developercertificate.org/).
under the Developer Certificate of Origin (https://developercertificate.org/).
Please see the Verilator manual for 200+ additional contributors. Thanks to
all.
Please see the Verilator manual for 200+ additional contributors. Thanks to all.
Ahmed El-Mahmoudy
Alex Chadwick
Chris Randall
Conor McCullough
Dan Petrisko
David Horton
David Stanford
Driss Hafdi
Edgar E. Iglesias
Eric Rippey
Fan Shupei
Garrett Smith
Geza Lore
Gianfranco Costamagna
Glen Gibb
Harald Heckmann
Howard Su
Huang Rui
Iztok Jeras
James Hanlon
James Hutchinson
Jamey Hicks
James Pallister
Jan Van Winkel
Jean Berniolles
Jeremy Bennett
John Coiner
John Demme
Josh Redford
Julien Margetts
Kaleb Barrett
Kanad Kanhere
Kevin Kiningham
Krzysztof Bieganski
Kuba Ober
Ludwig Rogiers
Lukasz Dalek
Maarten De Braekeleer
Maciej Sobkowski
Marco Widmer
Markus Krause
Marlon James
Marshal Qiao
Matthew Ballance
Michael Killough
Mike Popoloski
Nandu Raj
Nathan Kohagen
Nathan Myers
Patrick Stewart
Paul Wright
Peter Horvath
Peter Monsson
Philipp Wagner
Pieter Kapsenberg
Piotr Binkowski
Qingyao Sun
Rafal Kapuscik
Richard Myers
Rupert Swarbrick
Sean Cross
Sebastien Van Cauwenberghe
Sergi Granell
Stefan Wallentowitz
Stephen Henry
Tim Snyder
Tobias Rosenkranz
Tobias Wölfel
Todd Strader
Tomasz Gorochowik
Tymoteusz Blazejczyk
Unai Martinez-Corral
Victor Besyakov
Vassilis Papaefstathiou
Veripool API Bot
Wilson Snyder
Yossi Nivin
Yuri Victorovich
Yutetsu TAKATSUKASA
Yves Mathieu
HyungKi Jeong
+1 -1
View File
@@ -7,7 +7,7 @@
#
#*****************************************************************************
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# Copyright 2003-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
+2 -2
View File
@@ -1,6 +1,6 @@
// DESCRIPTION: Verilator: List of To Do issues.
//
// Copyright 2004-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2004-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -84,7 +84,7 @@
"if (a) { ... b=2; } else { ... b=2;}" -> "b=2; if ..."
Careful though, as b could appear in the statement or multiple times in statement
(Could just require exatly two 'b's in statement)
** Simplify XOR/XNOR/AND/OR bit selection trees
** Simplify XOR/AND/OR bit selection trees
Foo = A[1] ^ A[2] ^ A[3] etc are better as ^ ( A & 32'b...1110 )
** Combine variables into wider elements
Parallel statements on different bits should become single signal
-159
View File
@@ -1,159 +0,0 @@
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
+27 -30
View File
@@ -39,7 +39,7 @@ brief:
#sudo apt-get install libfl2 # Ubuntu only (ignore if gives error)
#sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
git clone https://git.veripool.org/git/verilator # Only first time
git clone https://github.com/verilator/verilator # Only first time
## Note the URL above is not a page you can see with a browser, it's for git only
# Every time you need to build:
@@ -69,40 +69,38 @@ Linux distribution, see instead <<Install From a Package Manager>>.
=== OS Requirements
Verilator is developed and has primary testing on Ubuntu. Versions have
also built on Redhat Linux, Apple OS-X, HPUX and Solaris. It should run
with minor porting on any GNU/Linux-ish platform. Verilator also works on
Windows under Cygwin, and Windows under MinGW (gcc -mno-cygwin). Verilated
output (not Verilator itself) compiles under all the options above, plus
MSVC++.
Verilator is developed and has primary testing on Ubuntu, with additional
testing on FreeBSD and Apple OS-X. Versions have also built on Redhat
Linux, HPUX and Solaris. It should run with minor porting on any
GNU/Linux-ish platform. Verilator also works on Windows under Cygwin, and
Windows under MinGW (gcc -mno-cygwin). Verilated output (not Verilator
itself) compiles under all the options above, plus MSVC++.
=== Install Prerequisites
To build Verilator you will need to install some standard packages:
To build or run Verilator you need these standard packages:
sudo apt-get install git
sudo apt-get install autoconf
sudo apt-get install flex bison
The following are optional, but improve compilation speed:
sudo apt-get install libgoogle-perftools-dev
Additionally, to build or run Verilator you need these standard packages:
sudo apt-get install perl python3
sudo apt-get install make
sudo apt-get install perl python3 make
sudo apt-get install g++ # Alternatively, clang
sudo apt-get install libgz # Non-Ubuntu (ignore if gives error)
sudo apt-get install libfl2 libfl-dev zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error)
Those developing Verilator may also want these (see internals.adoc):
To build or run the following are optional but should be installed for
good performance:
sudo apt-get install gdb asciidoctor graphviz cmake
sudo apt-get install ccache # If present at build, needed for run
sudo apt-get install libgoogle-perftools-dev numactl perl-doc
To build Verilator you will need to install these packages; these do not
need to be present to run Verilator:
sudo apt-get install git autoconf flex bison
Those developing Verilator itself may also want these (see internals.adoc):
sudo apt-get install gdb asciidoctor graphviz cmake clang clang-format gprof lcov
cpan install Pod::Perldoc
cpan install Unix::Processors
cpan install Parallel::Forker
cpan install Bit::Vector
==== Install SystemC
@@ -128,7 +126,7 @@ Downloads]; we presume you know how to use it, and is not described here.)
Get the sources from the repository: (You need do this only once, ever.)
git clone https://git.veripool.org/git/verilator # Only first time
git clone https://github.com/verilator/verilator # Only first time
## Note the URL above is not a page you can see with a browser, it's for git only
Enter the checkout and determine what version/branch to use:
@@ -264,10 +262,9 @@ set in your environment; it is built into the executable.
== Announcements
To get notified of new releases, login to
https://www.veripool.org[Veripool], and click the "watch" button near the
top right under https://www.veripool.org/projects/verilator/news[Verilator
News].
To get notified of new releases, go to
https://github.com/verilator/verilator-announce[Verilator announcement
repository] and follow the instructions there.
== Directory Structure
@@ -300,7 +297,7 @@ or https://verilator.org/verilator_doc.pdf[Verilator manual (PDF)].
== License
Copyright 2008-2020 by Wilson Snyder. Verilator is free software; you can
Copyright 2008-2021 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
+68 -39
View File
@@ -387,10 +387,8 @@ changed; if clear, checking those signals for changes may be skipped.
=== Compiler Version and C++11
Verilator supports GCC 4.4.7 and newer. GCC 4.4.7 does not support C++11,
therefore C++11 is generally not required. Exceptions may be made to
require C++11 for features that are only practical with C++11,
e.g. threads.
Verilator requires C++11. Verilator does not require any newer versions,
but is maintained to build successfully with C++14/C++17/C++20.
=== Indentation and Naming Style
@@ -405,6 +403,16 @@ This sets indentation to the `cc-mode` defaults. (Verilator predates a
CC-mode change of several years ago which overrides the defaults with GNU
style indentation; the `c-set-style` undoes that.)
* Use "mixedCapsSymbols" instead of "underlined_symbols".
* Uas a "p" suffix on variables that are pointers, e.g. "nodep".
* Comment every member variable.
Indentation is automatically maintained with "make format" using
clang-format version 10.0.0, and yapf for python, and is automatically
corrected in the CI actions. For those manually formatting C++ code:
* Use 4 spaces per level, and no tabs.
* Use 2 spaces between the end of source and the beginning of a comment.
@@ -414,12 +422,6 @@ style indentation; the `c-set-style` undoes that.)
* No spaces before semicolons, nor between a function's name and open
parenthesis (only applies to functions; if/else has a following space).
* Use "mixedCapsSymbols" instead of "underlined_symbols".
* Uas a "p" suffix on variables that are pointers, e.g. "nodep".
* Comment every member variable.
=== The `astgen` Script
Some of the code implementing passes is extremely repetitive, and must be
@@ -585,7 +587,7 @@ dealing with. For example a visitor might not implement separate `visit`
methods for `AstIf` and `AstGenIf`, but just a single method for the base
class:
void visit (AstNodeIf* nodep)
void visit(AstNodeIf* nodep)
However that method might want to specify additional code if it is called
for `AstGenIf`. Verilator does this by providing a `VN_IS` method for each
@@ -627,8 +629,6 @@ https://github.com/veripool/vcddiff
* Cmake for build paths that use it.
* Bit::Vector to test vgen.pl
=== Controlling the Test Driver
Test drivers are written in PERL. All invoke the main test driver script,
@@ -671,7 +671,7 @@ Set to 1 to indicate that the compilation or execution is intended to fail.
For example the following would specify that compilation requires two
defines and is expected to fail.
compile (
compile(
verilator_flags2 => ["-DSMALL_CLOCK -DGATED_COMMENT"],
fails => 1,
);
@@ -697,7 +697,7 @@ Verilator problem.
When enabling the long tests, some additional PERL modules are needed,
which you can install using cpan.
cpan install Unix::Processors
cpan install Parallel::Forker
There are some traps to avoid when running regression tests
@@ -729,20 +729,17 @@ test, run the following command.
=== Continuous Integration
Verilator has a https://travis-ci.com/verilator/verilator[Travis CI environment]
which automatically tests the master branch for test failures on new commits. It
also runs a daily cron job to validate all of the tests against different OS and
compiler versions.
Verilator uses GitHub Actions which automatically tests the master branch
for test failures on new commits. It also runs a daily cron job to validate
all of the tests against different OS and compiler versions.
Developers can connect Travis CI to their GitHub account so that the CI
environment can check their branches too by doing the following:
Developers can enable Actions on their GitHub repository so that the CI
environment can check their branches too by enabling the build workflow:
* Go to https://github.com/marketplace/travis-ci and follow the prompts
* Only the Open Source (FREE) version of Travis CI is required
* Under a Travis CI project click More options > Settings in order to set up a
cron job on a particular branch
* On GitHub, navigate to the main page of the repository.
* Under your repository name, click Actions.
* In the left sidebar, click the workflow you want to enable ("build").
* Click Enable workflow.
=== Fuzzing
@@ -757,6 +754,15 @@ may be required to setup the system for fuzzing.
== Debugging
=== Debug Levels
The "UINFO" calls in the source indicate a debug level. Messages level 3
and below are globally enabled with `--debug`. Higher levels may be
controlled with `--debugi <level>`. An individual source file levels may
be controlled with `-debugi-<srcfile> <level>`. For example `--debug
--debugi 5 --debugi-V3Width 9` will use the debug binary at default debug
level 5, with the V3Width.cpp file at level 9.
=== --debug
When you run with `--debug` there are two primary output file types placed
@@ -774,19 +780,20 @@ output, for example:
You can then print a.ps. You may prefer gif format, which doesn't get
scaled so can be more useful with large graphs.
For dynamic graph viewing consider
For interactive graph viewing consider
https://github.com/jrfonseca/xdot.py[xdot] or
http://zvtm.sourceforge.net/zgrviewer.html[ZGRViewer]. If you know of
better viewers let us know; ZGRViewer isn't great for large graphs.
better viewers (especially for large graphs) please let us know.
=== .tree Output
Tree files are dumps of the AST Tree and are produced between every major
algorithmic stage. An example:
NETLIST 0x90fb00 <e1> {a0}
1: MODULE 0x912b20 <e8822> {a8} top L2 [P]
*1:2: VAR 0x91a780 <e74#> {a22} @dt=0xa2e640(w32) out_wide [O] WIRE
1:2:1: BASICDTYPE 0xa2e640 <e2149> {e24} @dt=this(sw32) integer kwd=integer range=[31:0]
NETLIST 0x90fb00 <e1> {a0ah}
1: MODULE 0x912b20 <e8822> {a8ah} top L2 [P]
*1:2: VAR 0x91a780 <e74#> {a22ah} @dt=0xa2e640(w32) out_wide [O] WIRE
1:2:1: BASICDTYPE 0xa2e640 <e2149> {e24ah} @dt=this(sw32) integer kwd=integer range=[31:0]
The following summarizes the above example dump, with more detail on each
field in the section below.
@@ -804,8 +811,9 @@ the `MODULE`, which in turn is the `op1p` pointer under the `NETLIST`
| `<e74>` | means the 74th edit to the netlist was the last modification to
this node.
| `{a22}` | indicates this node is related to line 22 in the source filename
"a", where "a" is the first file read, "z" the 26th, and "aa" the 27th.
| `{a22ah}` | indicates this node is related to the source filename "a",
where "a" is the first file read, "z" the 26th, and "aa" the 27th. Then
line 22 in that file, then column 8 (aa=0, az=25, ba=26, ...).
| `@dt=0x...` | indicates the address of the data type this node contains.
@@ -846,7 +854,10 @@ correspond directly to Verilog entities (for example `MODULE` and
Address of the node::
A hexadecimal address of the node in memory. Useful for examining with the
debugger.
debugger. If the actual address values are not important, then using the
`--dump-tree-addrids` option will convert address values to short identifiers
of the form `([A-Z]*)`, which is hopefully easier for the reader to cross
reference throughout the dump.
Last edit number::
@@ -944,9 +955,9 @@ Then, when the watch fires, to break at every following change to that node:
To print a node:
pn nodep
# or: call nodep->dumpGdb() # aliased to "pn" in src/.gdbinit
# or: call dumpGdb(nodep) # aliased to "pn" in src/.gdbinit
pnt nodep
# or: call nodep->dumpTreeGdb() # aliased to "pnt" in src/.gdbinit
# or: call dumpTreeGdb(nodep) # aliased to "pnt" in src/.gdbinit
When GDB halts, it is useful to understand that the backtrace will commonly
show the iterator functions between each invocation of `visit` in the
@@ -993,9 +1004,27 @@ function in `src/verilator.cpp`.
To get your pass to build you'll need to add its binary filename to the
list in `src/Makefile_obj.in` and reconfigure.
=== "Never" features
Verilator ideally would support all of IEEE, and has the goal to get close
to full support. However the following IEEE sections and features are not
anticipated to be ever implemented for the reasons indicated.
[horizontal]
IEEE 1800-2017 3.3 recursive modules:: Little/no tool support, and arguably not a good practice.
IEEE 1800-2017 6.12 "shortreal":: Little/no tool support, and easily simply promoted to real.
IEEE 1800-2017 11.11 Min, typ, max:: No SDF support so will always use typical.
IEEE 1800-2017 11.12 "let":: Little/no tool support, makes difficult to implement parsers.
IEEE 1800-2017 20.15 Probabilistic functions:: Little industry use.
IEEE 1800-2017 20.16 Stochastic analysis:: Little industry use.
IEEE 1800-2017 20.17 PLA modeling:: Little industry use and outdated technology.
IEEE 1800-2017 31 Timing checks:: No longer relevant with static timing analysis tools.
IEEE 1800-2017 32 SDF annotation:: No longer relevant with static timing analysis tools.
IEEE 1800-2017 33 Config:: Little/no tool support or industry use.
== Distribution
Copyright 2008-2020 by Wilson Snyder. Verilator is free software; you can
Copyright 2008-2021 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
+2 -2
View File
@@ -21,7 +21,7 @@ parser.
== Structure
The XML document is consists of 4 sections within the top level `verilator_xml`
The XML document consists of 4 sections within the top level `verilator_xml`
element:
`<files>`...`</files>`::
@@ -66,7 +66,7 @@ elements in the `<module>` elements using the `dtype_id` attribute.
== Distribution
Copyright 2020-2020 by Wilson Snyder. Verilator is free software; you can
Copyright 2020-2021 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 -5
View File
@@ -5,11 +5,9 @@
# This is an example cmake script to build a verilog to systemc project
# using cmake and verilator.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
+5 -7
View File
@@ -6,11 +6,9 @@
# This makefile is here for testing the examples and should
# generally not be added to a CMake project.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -51,11 +49,11 @@ run:
@echo "-- Verilator CMake hello world example"
@echo
@echo "-- CMake ----------------"
@echo "-- VERILATE ----------------"
mkdir -p build && cd build && cmake ..
@echo
@echo "-- COMPILE -----------------"
@echo "-- BUILD -------------------"
cmake --build build
@echo
+3 -5
View File
@@ -5,11 +5,9 @@
# This is an example cmake script to build a verilog to SystemC project
# using CMake and Verilator.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
+5 -7
View File
@@ -6,11 +6,9 @@
# This makefile is here for testing the examples and should
# generally not be added to a CMake project.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -87,11 +85,11 @@ run:
@echo "-- Verilator CMake SystemC hello-world simple example"
@echo
@echo "-- CMake ----------------"
@echo "-- VERILATE ----------------"
mkdir -p build && cd build && cmake ..
@echo
@echo "-- COMPILE -----------------"
@echo "-- BUILD -------------------"
cmake --build build
@echo
+3 -5
View File
@@ -5,11 +5,9 @@
# This is an example cmake script to build a verilog to systemc project
# using cmake and verilator.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
+5 -7
View File
@@ -6,11 +6,9 @@
# This makefile is here for testing the examples and should
# generally not be added to a CMake project.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -51,11 +49,11 @@ run:
@echo "-- Verilator CMake protect_lib example"
@echo
@echo "-- CMake ----------------"
@echo "-- VERILATE ----------------"
mkdir -p build && cd build && cmake ..
@echo
@echo "-- COMPILE -----------------"
@echo "-- BUILD -------------------"
cmake --build build
@echo
+3 -5
View File
@@ -5,11 +5,9 @@
# This is an example cmake script to build a verilog to systemc project
# using cmake and verilator.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
+5 -7
View File
@@ -6,11 +6,9 @@
# This makefile is here for testing the examples and should
# generally not be added to a CMake project.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -51,11 +49,11 @@ run:
@echo "-- Verilator CMake tracing example"
@echo
@echo "-- CMake ----------------"
@echo "-- VERILATE ----------------"
mkdir -p build && cd build && cmake ..
@echo
@echo "-- COMPILE -----------------"
@echo "-- BUILD -------------------"
cmake --build build
@echo
+3 -5
View File
@@ -5,11 +5,9 @@
# This is an example cmake script to build a verilog to SystemC project
# using CMake and Verilator.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
+5 -7
View File
@@ -6,11 +6,9 @@
# This makefile is here for testing the examples and should
# generally not be added to a CMake project.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -87,11 +85,11 @@ run:
@echo "-- Verilator CMake SystemC tracing example"
@echo
@echo "-- CMake ----------------"
@echo "-- VERILATE ----------------"
mkdir -p build && cd build && cmake ..
@echo
@echo "-- COMPILE -----------------"
@echo "-- BUILD -------------------"
cmake --build build
@echo
+5 -9
View File
@@ -5,11 +5,9 @@
# This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
@@ -36,10 +34,8 @@ endif
default:
@echo "-- Verilator hello-world simple example"
@echo "-- VERILATE ----------------"
$(VERILATOR) -cc --exe top.v sim_main.cpp
@echo "-- COMPILE -----------------"
$(MAKE) -j 4 -C obj_dir -f Vtop.mk
@echo "-- VERILATE & BUILD --------"
$(VERILATOR) -cc --exe --build -j top.v sim_main.cpp
@echo "-- RUN ---------------------"
obj_dir/Vtop
@echo "-- DONE --------------------"
+2 -2
View File
@@ -19,7 +19,7 @@ int main(int argc, char** argv, char** env) {
// e.g. examples/c_tracing.
// Prevent unused variable warnings
if (0 && argc && argv && env) {}
if (false && argc && argv && env) {}
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
Vtop* top = new Vtop;
@@ -37,6 +37,6 @@ int main(int argc, char** argv, char** env) {
// Destroy model
delete top;
// Fin
// Return good completion status
exit(0);
}
+5 -9
View File
@@ -5,11 +5,9 @@
# This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
@@ -45,10 +43,8 @@ endif
run:
@echo "-- Verilator hello-world simple example"
@echo "-- VERILATE ----------------"
$(VERILATOR) -sc --exe top.v sc_main.cpp
@echo "-- COMPILE -----------------"
$(MAKE) -j 4 -C obj_dir -f Vtop.mk
@echo "-- VERILATE & COMPILE ------"
$(VERILATOR) -sc --exe --build -j top.v sc_main.cpp
@echo "-- RUN ---------------------"
obj_dir/Vtop
@echo "-- DONE --------------------"
+5 -12
View File
@@ -23,30 +23,23 @@ int sc_main(int argc, char* argv[]) {
// e.g. examples/c_tracing.
// Prevent unused variable warnings
if (0 && argc && argv) {}
if (false && argc && argv) {}
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
Vtop* top = new Vtop("top");
// Initialize SC model
#if (SYSTEMC_VERSION>=20070314)
sc_start(1,SC_NS);
#else
sc_start(1);
#endif
sc_start(1, SC_NS);
// Simulate until $finish
while (!Verilated::gotFinish()) {
#if (SYSTEMC_VERSION>=20070314)
sc_start(1,SC_NS);
#else
sc_start(1);
#endif
// Simulate 1ns
sc_start(1, SC_NS);
}
// Final model cleanup
top->final();
// Fin
// Return good completion status
return 0;
}
+4 -6
View File
@@ -5,11 +5,9 @@
# This calls the object directory makefiles. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# Copyright 2019 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# This file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
@@ -70,7 +68,7 @@ run:
@echo " library (libverilated_secret.a) generated from the previous"
@echo " step"
@echo "---------------------------------------------------------------"
$(VERILATOR) $(TOP_VERILATOR_FLAGS) --exe -LDFLAGS '-L../obj_dir_secret -lverilated_secret -static' top.v obj_dir_secret/verilated_secret.sv sim_main.cpp
$(VERILATOR) $(TOP_VERILATOR_FLAGS) --exe -LDFLAGS '../obj_dir_secret/libverilated_secret.a' top.v obj_dir_secret/verilated_secret.sv sim_main.cpp
@echo
@echo "-- COMPILE entire design --------------------------------------"
+9 -7
View File
@@ -6,14 +6,16 @@
// This module will be used as libsecret.a or libsecret.so without
// exposing the source.
module secret_impl(
input [31:0] a,
input [31:0] b,
output logic [31:0] x,
input clk);
logic [31:0] accum_q = 0;
logic [31:0] secret_value = 9;
module secret_impl
(
input [31:0] a,
input [31:0] b,
output logic [31:0] x,
input clk);
logic [31:0] accum_q = 0;
logic [31:0] secret_value = 9;
initial $display("%m: initialized");
+12 -10
View File
@@ -13,16 +13,14 @@
#include "Vtop.h"
#if VM_TRACE
# include <verilated_vcd_c.h>
#include <verilated_vcd_c.h>
#endif
vluint64_t main_time = 0;
double sc_time_stamp() {
return main_time;
}
double sc_time_stamp() { return main_time; }
int main(int argc, char** argv, char** env) {
if (0 && argc && argv && env) {}
if (false && argc && argv && env) {}
Verilated::debug(0);
Verilated::randReset(2);
@@ -33,9 +31,9 @@ int main(int argc, char** argv, char** env) {
#if VM_TRACE
// When tracing, the contents of the secret module will not be seen
VerilatedVcdC* tfp = NULL;
VerilatedVcdC* tfp = nullptr;
const char* flag = Verilated::commandArgsPlusMatch("trace");
if (flag && 0==strcmp(flag, "+trace")) {
if (flag && 0 == strcmp(flag, "+trace")) {
Verilated::traceEverOn(true);
VL_PRINTF("Enabling waves into logs/vlt_dump.vcd...\n");
tfp = new VerilatedVcdC;
@@ -62,12 +60,16 @@ int main(int argc, char** argv, char** env) {
// Close trace if opened
#if VM_TRACE
if (tfp) { tfp->close(); tfp = NULL; }
if (tfp) {
tfp->close();
tfp = nullptr;
}
#endif
// Destroy model
delete top; top = NULL;
delete top;
top = nullptr;
// Fin
// Return good completion status
exit(0);
}
+10 -10
View File
@@ -5,11 +5,9 @@
# This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
@@ -68,11 +66,13 @@ run:
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_INPUT)
@echo
@echo "-- COMPILE -----------------"
# To compile, we can either just do what Verilator asks,
# or call a submakefile where we can override the rules ourselves
# $(MAKE) -j 4 -C obj_dir -f Vtop.mk
$(MAKE) -j 4 -C obj_dir -f ../Makefile_obj
@echo "-- BUILD -------------------"
# To compile, we can either
# 1. Pass --build to Verilator by editing VERILATOR_FLAGS above.
# 2. Or, run the make rules Verilator does:
# $(MAKE) -j -C obj_dir -f Vtop.mk
# 3. Or, call a submakefile where we can override the rules ourselves:
$(MAKE) -j -C obj_dir -f ../Makefile_obj
@echo
@echo "-- RUN ---------------------"
+3 -5
View File
@@ -5,11 +5,9 @@
#
# This is executed in the object directory, and called by ../Makefile
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
#######################################################################
+10 -9
View File
@@ -5,6 +5,9 @@
// SPDX-License-Identifier: CC0-1.0
//======================================================================
// For std::unique_ptr
#include <memory>
// Include common routines
#include <verilated.h>
@@ -22,7 +25,7 @@ int main(int argc, char** argv, char** env) {
// This is a more complicated example, please also see the simpler examples/make_hello_c.
// Prevent unused variable warnings
if (0 && argc && argv && env) {}
if (false && argc && argv && env) {}
// Set debug level, 0 is off, 9 is highest presently used
// May be overridden by commandArgs
@@ -43,7 +46,8 @@ int main(int argc, char** argv, char** env) {
Verilated::mkdir("logs");
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
Vtop* top = new Vtop; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper
// Using unique_ptr is similar to "Vtop* top = new Vtop" then deleting at end
const std::unique_ptr<Vtop> top{new Vtop};
// Set some inputs
top->reset_l = !0;
@@ -83,9 +87,9 @@ int main(int argc, char** argv, char** env) {
// Read outputs
VL_PRINTF("[%" VL_PRI64 "d] clk=%x rstl=%x iquad=%" VL_PRI64 "x"
" -> oquad=%" VL_PRI64"x owide=%x_%08x_%08x\n",
main_time, top->clk, top->reset_l, top->in_quad,
top->out_quad, top->out_wide[2], top->out_wide[1], top->out_wide[0]);
" -> oquad=%" VL_PRI64 "x owide=%x_%08x_%08x\n",
main_time, top->clk, top->reset_l, top->in_quad, top->out_quad, top->out_wide[2],
top->out_wide[1], top->out_wide[0]);
}
// Final model cleanup
@@ -97,9 +101,6 @@ int main(int argc, char** argv, char** env) {
VerilatedCov::write("logs/coverage.dat");
#endif
// Destroy model
delete top; top = NULL;
// Fin
// Return good completion status
exit(0);
}
+5 -5
View File
@@ -11,15 +11,15 @@
module top
(
// Declare some signals so we can see how I/O works
input clk,
input reset_l,
input clk,
input reset_l,
output wire [1:0] out_small,
output wire [39:0] out_quad,
output wire [69:0] out_wide,
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
);
// Connect up the outputs, using some trivial logic
+9 -9
View File
@@ -5,11 +5,9 @@
# This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
@@ -77,10 +75,12 @@ run:
@echo
@echo "-- COMPILE -----------------"
# To compile, we can either just do what Verilator asks,
# or call a submakefile where we can override the rules ourselves
# $(MAKE) -j 4 -C obj_dir -f Vtop.mk
$(MAKE) -j 4 -C obj_dir -f ../Makefile_obj
# To compile, we can either
# 1. Pass --build to Verilator by editing VERILATOR_FLAGS above.
# 2. Or, run the make rules Verilator does:
# $(MAKE) -j -C obj_dir -f Vtop.mk
# 3. Or, call a submakefile where we can override the rules ourselves:
$(MAKE) -j -C obj_dir -f ../Makefile_obj
@echo
@echo "-- RUN ---------------------"
+5 -7
View File
@@ -5,11 +5,9 @@
#
# This is executed in the object directory, and called by ../Makefile
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
#######################################################################
@@ -39,8 +37,8 @@ endif
# If you build your own rules from scratch, note you need to include
# SystemC as follows (Vtop.mk file includes verilated.mk with these
# already).
# CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC_INCLUDE)
# LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC_LIBDIR)
# CPPFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -I, $(SYSTEMC_INCLUDE))
# LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR))
# See the benchmarking section of bin/verilator.
# Support class optimizations. This includes the tracing and symbol table.
+31 -46
View File
@@ -6,6 +6,9 @@
// SPDX-License-Identifier: CC0-1.0
//======================================================================
// For std::unique_ptr
#include <memory>
// SystemC global header
#include <systemc.h>
@@ -24,7 +27,7 @@ int sc_main(int argc, char* argv[]) {
// This is a more complicated example, please also see the simpler examples/make_hello_c.
// Prevent unused variable warnings
if (0 && argc && argv) {}
if (false && argc && argv) {}
// Set debug level, 0 is off, 9 is highest presently used
// May be overridden by commandArgs
@@ -44,43 +47,33 @@ int sc_main(int argc, char* argv[]) {
// General logfile
ios::sync_with_stdio();
// Defaults time
#if (SYSTEMC_VERSION>20011000)
#else
sc_time dut(1.0, sc_ns);
sc_set_default_time_unit(dut);
#endif
// Define clocks
#if (SYSTEMC_VERSION>=20070314)
sc_clock clk ("clk", 10,SC_NS, 0.5, 3,SC_NS, true);
sc_clock fastclk ("fastclk", 2,SC_NS, 0.5, 2,SC_NS, true);
#else
sc_clock clk ("clk", 10, 0.5, 3, true);
sc_clock fastclk ("fastclk", 2, 0.5, 2, true);
#endif
sc_clock clk{"clk", 10, SC_NS, 0.5, 3, SC_NS, true};
sc_clock fastclk{"fastclk", 2, SC_NS, 0.5, 2, SC_NS, true};
// Define interconnect
sc_signal<bool> reset_l;
sc_signal<vluint32_t> in_small;
sc_signal<vluint64_t> in_quad;
sc_signal<sc_bv<70> > in_wide;
sc_signal<sc_bv<70>> in_wide;
sc_signal<vluint32_t> out_small;
sc_signal<vluint64_t> out_quad;
sc_signal<sc_bv<70> > out_wide;
sc_signal<sc_bv<70>> out_wide;
// Construct the Verilated model, from inside Vtop.h
Vtop* top = new Vtop("top");
// Using unique_ptr is similar to "Vtop* top = new Vtop" then deleting at end
const std::unique_ptr<Vtop> top{new Vtop{"top"}};
// Attach signals to the model
top->clk (clk);
top->fastclk (fastclk);
top->reset_l (reset_l);
top->in_small (in_small);
top->in_quad (in_quad);
top->in_wide (in_wide);
top->out_small (out_small);
top->out_quad (out_quad);
top->out_wide (out_wide);
top->clk(clk);
top->fastclk(fastclk);
top->reset_l(reset_l);
top->in_small(in_small);
top->in_quad(in_quad);
top->in_wide(in_wide);
top->out_small(out_small);
top->out_quad(out_quad);
top->out_wide(out_wide);
#if VM_TRACE
// Before any evaluation, need to know to calculate those signals only used for tracing
@@ -89,18 +82,14 @@ int sc_main(int argc, char* argv[]) {
// You must do one evaluation before enabling waves, in order to allow
// SystemC to interconnect everything for testing.
#if (SYSTEMC_VERSION>=20070314)
sc_start(1,SC_NS);
#else
sc_start(1);
#endif
sc_start(1, SC_NS);
#if VM_TRACE
// If verilator was invoked with --trace argument,
// and if at run time passed the +trace argument, turn on tracing
VerilatedVcdSc* tfp = NULL;
VerilatedVcdSc* tfp = nullptr;
const char* flag = Verilated::commandArgsPlusMatch("trace");
if (flag && 0==strcmp(flag, "+trace")) {
if (flag && 0 == strcmp(flag, "+trace")) {
cout << "Enabling waves into logs/vlt_dump.vcd...\n";
tfp = new VerilatedVcdSc;
top->trace(tfp, 99); // Trace 99 levels of hierarchy
@@ -118,18 +107,14 @@ int sc_main(int argc, char* argv[]) {
#endif
// Apply inputs
if (VL_TIME_Q() > 1 && VL_TIME_Q() < 10) {
if (sc_time_stamp() > sc_time(1, SC_NS) && sc_time_stamp() < sc_time(10, SC_NS)) {
reset_l = !1; // Assert reset
} else if (VL_TIME_Q() > 1) {
} else {
reset_l = !0; // Deassert reset
}
// Simulate 1ns
#if (SYSTEMC_VERSION>=20070314)
sc_start(1,SC_NS);
#else
sc_start(1);
#endif
sc_start(1, SC_NS);
}
// Final model cleanup
@@ -137,7 +122,10 @@ int sc_main(int argc, char* argv[]) {
// Close trace if opened
#if VM_TRACE
if (tfp) { tfp->close(); tfp = NULL; }
if (tfp) {
tfp->close();
tfp = nullptr;
}
#endif
// Coverage analysis (since test passed)
@@ -146,9 +134,6 @@ int sc_main(int argc, char* argv[]) {
VerilatedCov::write("logs/coverage.dat");
#endif
// Destroy model
delete top; top = NULL;
// Fin
// Return good completion status
return 0;
}
+6 -6
View File
@@ -11,16 +11,16 @@
module top
(
// Declare some signals so we can see how I/O works
input clk,
input fastclk,
input reset_l,
input clk,
input fastclk,
input reset_l,
output wire [1:0] out_small,
output wire [39:0] out_quad,
output wire [69:0] out_wide,
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
);
// Connect up the outputs, using some trivial logic
+7 -9
View File
@@ -2,11 +2,9 @@
#
# DESCRIPTION: Verilator Example: XML tests
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# 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 file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
@@ -24,9 +22,9 @@ VERILATOR = $(VERILATOR_ROOT)/bin/verilator
endif
DOT = dot
PYTHON = python3
PYTHON3 = python3
PYTHON_VERSION := $(shell ${PYTHON} --version 2>&1)
PYTHON_VERSION := $(shell ${PYTHON3} --version 2>&1)
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,${PYTHON_VERSION}))
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
PYTHON_VERSION_MINOR := $(word 2,${PYTHON_VERSION_FULL})
@@ -47,13 +45,13 @@ test: \
test-vl_file_copy:
@echo "-- vl_file_copy example"
$(PYTHON) vl_file_copy -odir copied top.v
$(PYTHON3) vl_file_copy -odir copied top.v
@cmp copied/top.v top.v
@cmp copied/sub.v sub.v
test-vl_hier_graph:
@echo "-- vl_hier_graph example"
$(PYTHON) vl_hier_graph -o graph.dot top.v
$(PYTHON3) vl_hier_graph -o graph.dot top.v
@echo "Manually run: " $(DOT) -Tpdf -o graph.pdf graph.dot
######################################################################
+1 -1
View File
@@ -8,7 +8,7 @@
module sub
#(parameter type TYPE_t = logic)
(
input TYPE_t in,
input TYPE_t in,
output TYPE_t out
);
+6 -6
View File
@@ -7,16 +7,16 @@
module top
(
input clk,
input fastclk,
input reset_l,
input clk,
input fastclk,
input reset_l,
output wire [1:0] out_small,
output wire [39:0] out_quad,
output wire [69:0] out_wide,
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
input [1:0] in_small,
input [39:0] in_quad,
input [69:0] in_wide
);
sub #(.TYPE_t(logic [1:0])) sub_small
+35 -25
View File
@@ -10,24 +10,29 @@ import sys
import tempfile
import xml.etree.ElementTree as ET
from shutil import copy2
from pprint import pprint,pformat
from pprint import pprint, pformat
#######################################################################
class VlFileCopy:
def __init__(self,
verilator_args, # presently all verilator options are passed-thru
# ideally this script would check against options mentioned in help
debug=0,
output_dir='copied'): # directory name we output file uses
def __init__(
self,
verilator_args, # presently all verilator options are passed-thru
# ideally this script would check against options mentioned in help
debug=0,
output_dir='copied'): # directory name we output file uses
self.debug = debug
xml_temp = tempfile.NamedTemporaryFile()
args = ['--xml-output', xml_temp.name,
'--bbox-sys', # Parse some stuff can't translate
'--bbox-unsup',
'--prefix vlxml'] # So we know name of .xml output
args = [
'--xml-output',
xml_temp.name,
'--bbox-sys', # Parse some stuff can't translate
'--bbox-unsup',
'--prefix vlxml'
] # So we know name of .xml output
args += verilator_args
self.run_verilator(args)
self.tree = ET.parse(xml_temp.name)
@@ -55,16 +60,18 @@ class VlFileCopy:
print("\t%s " % command)
status = subprocess.call(command, shell=True)
if status != 0:
raise Exception("Command failed running Verilator with '"+command+"', stopped")
raise Exception("Command failed running Verilator with '" +
command + "', stopped")
#######################################################################
if __name__=='__main__':
if __name__ == '__main__':
parser = argparse.ArgumentParser(
allow_abbrev=False,
formatter_class=argparse.RawTextHelpFormatter,
description=
"""Example of using Verilator XML output to copy a list of files to an
"""Example of using Verilator XML output to copy a list of files to an
output directory (-odir, defaults to 'copied'), e.g. to easily create a
tarball of the design to pass to others.
@@ -72,8 +79,7 @@ Example usage:
vl_file_copy -f input.vc top.v -odir mycopy
# This will make at least mycopy/top.v
""",
epilog=
"""All other arguments are pass-thru to Verilator: e.g.:
epilog="""All other arguments are pass-thru to Verilator: e.g.:
+define+<var>=<value> Set preprocessor define
-F <file> Parse options from a file, relatively
@@ -87,26 +93,30 @@ Example usage:
This file ONLY is placed under the Creative Commons Public Domain, for
any use, without warranty, 2019 by Wilson Snyder.
SPDX-License-Identifier: CC0-1.0
"""
)
parser.add_argument('-debug', '--debug',
action='store_const', const=9,
""")
parser.add_argument('-debug',
'--debug',
action='store_const',
const=9,
help='enable debug')
parser.add_argument('-odir', '--odir',
action='store', metavar='directory', required=True,
parser.add_argument('-odir',
'--odir',
action='store',
metavar='directory',
required=True,
help='target output directory')
(args, rem) = parser.parse_known_args()
print("NOTE: vl_file_copy is only an example starting point for writing your own tool.")
print(
"NOTE: vl_file_copy is only an example starting point for writing your own tool."
)
# That is:
# 1. We will accept basic patches
# 2. We are not expecting to make this globally useful. (e.g. we don't cleanup obj_dir)
# 3. "make install" will not install this.
# 4. This has not had production-worthy validation.
fc = VlFileCopy(output_dir = args.odir,
debug = args.debug,
verilator_args = rem)
fc = VlFileCopy(output_dir=args.odir, debug=args.debug, verilator_args=rem)
######################################################################
### Local Variables:
+43 -30
View File
@@ -10,26 +10,31 @@ import sys
import tempfile
import xml.etree.ElementTree as ET
from shutil import copy2
from pprint import pprint,pformat
from pprint import pprint, pformat
#######################################################################
class VlHierGraph:
def __init__(self,
verilator_args, # presently all verilator options are passed-thru
# ideally this script would check against options mentioned in help
debug=0,
output_filename='graph.dot'): # output filename
def __init__(
self,
verilator_args, # presently all verilator options are passed-thru
# ideally this script would check against options mentioned in help
debug=0,
output_filename='graph.dot'): # output filename
self.debug = debug
self.next_vertex_number = 0
self.name_to_number = {}
xml_temp = tempfile.NamedTemporaryFile()
args = ['--xml-output', xml_temp.name,
'--bbox-sys', # Parse some stuff can't translate
'--bbox-unsup',
'--prefix vlxml'] # So we know name of .xml output
args = [
'--xml-output',
xml_temp.name,
'--bbox-sys', # Parse some stuff can't translate
'--bbox-unsup',
'--prefix vlxml'
] # So we know name of .xml output
args += verilator_args
self.run_verilator(args)
self.tree = ET.parse(xml_temp.name)
@@ -39,7 +44,9 @@ class VlHierGraph:
fh.write("digraph {\n")
fh.write(" dpi=300;\n")
fh.write(" order=LR;\n")
fh.write(" node [fontsize=8 shape=\"box\" margin=0.01 width=0 height=0]")
fh.write(
" node [fontsize=8 shape=\"box\" margin=0.01 width=0 height=0]"
)
fh.write(" edge [fontsize=6]")
# Find cells
root = self.tree.getroot()
@@ -48,8 +55,7 @@ class VlHierGraph:
# origNames are before parameterization, name if after
mod_name = module.get('name')
mod_number = self.name_to_vertex_number(mod_name)
fh.write(" n%d [label=\"%s\""
% (mod_number, mod_name))
fh.write(" n%d [label=\"%s\"" % (mod_number, mod_name))
if module.get('topModule'):
fh.write(" color=\"red\" rank=1")
fh.write("];\n")
@@ -58,8 +64,8 @@ class VlHierGraph:
inst_name = instance.get('name')
def_name = instance.get('defName')
def_number = self.name_to_vertex_number(def_name)
fh.write(" n%d->n%d [label=\"%s\"];\n"
% (mod_number, def_number, inst_name));
fh.write(" n%d->n%d [label=\"%s\"];\n" %
(mod_number, def_number, inst_name))
fh.write("}\n")
@@ -80,24 +86,25 @@ class VlHierGraph:
print("\t%s " % command)
status = subprocess.call(command, shell=True)
if status != 0:
raise Exception("Command failed running Verilator with '"+command+"', stopped")
raise Exception("Command failed running Verilator with '" +
command + "', stopped")
#######################################################################
if __name__=='__main__':
if __name__ == '__main__':
parser = argparse.ArgumentParser(
allow_abbrev=False,
formatter_class=argparse.RawTextHelpFormatter,
description=
"""Example of using Verilator XML output to create a .dot file showing the
"""Example of using Verilator XML output to create a .dot file showing the
design module hierarchy.
Example usage:
vl_hier_graph -f input.vc top.v -o graph.dot
dot -Tpdf -o graph.pdf graph.dot
""",
epilog=
"""All other arguments are pass-thru to Verilator: e.g.:
epilog="""All other arguments are pass-thru to Verilator: e.g.:
+define+<var>=<value> Set preprocessor define
-F <file> Parse options from a file, relatively
@@ -111,26 +118,32 @@ Example usage:
This file ONLY is placed under the Creative Commons Public Domain, for
any use, without warranty, 2019 by Wilson Snyder.
SPDX-License-Identifier: CC0-1.0
"""
)
parser.add_argument('-debug', '--debug',
action='store_const', const=9,
""")
parser.add_argument('-debug',
'--debug',
action='store_const',
const=9,
help='enable debug')
parser.add_argument('-o', '--o',
action='store', metavar='filename', required=True,
parser.add_argument('-o',
'--o',
action='store',
metavar='filename',
required=True,
help='output filename')
(args, rem) = parser.parse_known_args()
print("NOTE: vl_hier_graph is only an example starting point for writing your own tool.")
print(
"NOTE: vl_hier_graph is only an example starting point for writing your own tool."
)
# That is:
# 1. We will accept basic patches
# 2. We are not expecting to make this globally useful. (e.g. we don't cleanup obj_dir)
# 3. "make install" will not install this.
# 4. This has not had production-worthy validation.
fc = VlHierGraph(output_filename = args.o,
debug = args.debug,
verilator_args = rem)
fc = VlHierGraph(output_filename=args.o,
debug=args.debug,
verilator_args=rem)
######################################################################
### Local Variables:
+1 -1
View File
@@ -3,7 +3,7 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). */
#if !defined(__MINGW32__)
#if !defined(__MINGW32__) && !defined(__FreeBSD__)
# define HAVE_ALLOCA_H 1
#endif
+21 -2
View File
@@ -794,6 +794,7 @@ pthread_t thread;
pthread_attr_t thread_attr;
struct fstWriterContext *xc_parent;
#endif
unsigned in_pthread : 1;
size_t fst_orig_break_size;
size_t fst_orig_break_add_size;
@@ -1805,19 +1806,23 @@ xc->already_in_flush = 0;
static void *fstWriterFlushContextPrivate1(void *ctx)
{
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
struct fstWriterContext *xc_parent;
pthread_mutex_lock(&(xc->xc_parent->mutex));
fstWriterFlushContextPrivate2(xc);
pthread_mutex_unlock(&(xc->xc_parent->mutex));
#ifdef FST_REMOVE_DUPLICATE_VC
free(xc->curval_mem);
#endif
free(xc->valpos_mem);
free(xc->vchg_mem);
tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
xc_parent = xc->xc_parent;
free(xc);
xc_parent->in_pthread = 0;
pthread_mutex_unlock(&(xc_parent->mutex));
return(NULL);
}
@@ -1865,7 +1870,15 @@ if(xc->parallel_enabled)
xc->section_header_only = 0;
xc->secnum++;
while (xc->in_pthread)
{
pthread_mutex_lock(&xc->mutex);
pthread_mutex_unlock(&xc->mutex);
};
pthread_mutex_lock(&xc->mutex);
xc->in_pthread = 1;
pthread_mutex_unlock(&xc->mutex);
pthread_create(&xc->thread, &xc->thread_attr, fstWriterFlushContextPrivate1, xc2);
}
@@ -1947,6 +1960,12 @@ if(xc && !xc->already_in_close && !xc->already_in_flush)
#ifdef FST_WRITER_PARALLEL
pthread_mutex_lock(&xc->mutex);
pthread_mutex_unlock(&xc->mutex);
while (xc->in_pthread)
{
pthread_mutex_lock(&xc->mutex);
pthread_mutex_unlock(&xc->mutex);
};
#endif
}
}
+1086 -743
View File
File diff suppressed because it is too large Load Diff
+866 -676
View File
File diff suppressed because it is too large Load Diff
+98 -52
View File
@@ -2,7 +2,7 @@
######################################################################
# DESCRIPTION: Makefile commands for all verilated target files
#
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# Copyright 2003-2021 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
@@ -12,8 +12,9 @@
PERL = @PERL@
CXX = @CXX@
LINK = @CXX@
AR = ar
AR = ar
RANLIB = ranlib
OBJCACHE ?= @OBJCACHE@
CFG_WITH_CCWARN = @CFG_WITH_CCWARN@
CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@
@@ -53,6 +54,7 @@ VK_CPPFLAGS_ALWAYS += \
-DVM_COVERAGE=$(VM_COVERAGE) \
-DVM_SC=$(VM_SC) \
-DVM_TRACE=$(VM_TRACE) \
-DVM_TRACE_FST=$(VM_TRACE_FST) \
$(CFG_CXXFLAGS_NO_UNUSED) \
ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users
@@ -83,27 +85,29 @@ CPPFLAGS += $(VM_USER_CFLAGS)
LDFLAGS += $(VM_USER_LDFLAGS)
LDLIBS += $(VM_USER_LDLIBS)
# See the benchmarking section of bin/verilator.
# Support class optimizations. This includes the tracing and symbol table.
# SystemC takes minutes to optimize, thus it is off by default.
#OPT_SLOW =
# Fast path optimizations. Most time is spent in these classes.
#OPT_FAST = -Os -fstrict-aliasing
#OPT_FAST = -O
#OPT_FAST =
######################################################################
# Optimization control.
#######################################################################
##### Aggregates
# See also the BENCHMARKING & OPTIMIZATION section of the manual.
VM_CLASSES += $(VM_CLASSES_FAST) $(VM_CLASSES_SLOW)
VM_SUPPORT += $(VM_SUPPORT_FAST) $(VM_SUPPORT_SLOW)
# Optimization flags for non performance-critical/rarely executed code.
# No optimization by default, which improves compilation speed.
OPT_SLOW =
# Optimization for performance critical/hot code. Most time is spent in these
# routines. Optimizing by default for improved execution speed.
OPT_FAST = -Os
# Optimization applied to the common run-time library used by verilated models.
# For compatibility this is called OPT_GLOBAL even though it only applies to
# files in the run-time library. Normally there should be no need for the user
# to change this as the library is small, but can have significant speed impact.
OPT_GLOBAL = -Os
#######################################################################
##### SystemC builds
ifeq ($(VM_SC),1)
CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC_INCLUDE)
LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC_LIBDIR)
CPPFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -I, $(SYSTEMC_INCLUDE))
LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR))
SC_LIBS = -lsystemc
ifneq ($(wildcard $(SYSTEMC_LIBDIR)/*numeric_bit*),)
# Systemc 1.2.1beta
@@ -114,85 +118,127 @@ endif
#######################################################################
##### Threaded builds
ifneq ($(VM_C11),0)
ifneq ($(VM_C11),)
VK_C11=1
endif
endif
ifneq ($(VM_THREADS),0)
ifneq ($(VM_THREADS),)
CPPFLAGS += -DVL_THREADED
VK_C11=1
VK_LIBS_THREADED=1
endif
endif
ifneq ($(VM_TRACE_THREADED),0)
ifneq ($(VM_TRACE_THREADED),)
ifneq ($(VM_TRACE_THREADS),0)
ifneq ($(VM_TRACE_THREADS),)
ifeq ($(findstring -DVL_THREADED,$(CPPFLAGS)),)
$(error VM_TRACE_THREADS requires VM_THREADS)
endif
CPPFLAGS += -DVL_TRACE_THREADED
VK_C11=1
VK_LIBS_THREADED=1
endif
endif
ifneq ($(VM_TRACE_FST_WRITER_THREAD),0)
ifneq ($(VM_TRACE_FST_WRITER_THREAD),)
CPPFLAGS += -DVL_TRACE_FST_WRITER_THREAD
VK_C11=1
VK_LIBS_THREADED=1
endif
endif
ifneq ($(VK_C11),0)
ifneq ($(VK_C11),)
# Need C++11 at least, so always default to newest
CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST)
endif
endif
ifneq ($(VK_LIBS_THREADED),0)
ifneq ($(VK_LIBS_THREADED),)
# Need C++11 at least, so always default to newest
CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST)
LDLIBS += $(CFG_LDLIBS_THREADS)
endif
endif
#######################################################################
##### Stub
### Aggregates
preproc:
VM_FAST += $(VM_CLASSES_FAST) $(VM_SUPPORT_FAST)
VM_SLOW += $(VM_CLASSES_SLOW) $(VM_SUPPORT_SLOW)
#######################################################################
##### C/H builds
### Overall Objects Linking
LIBS += -lm -lstdc++
#######################################################################
# Overall Objects Linking
VK_CLASSES_H = $(addsuffix .h, $(VM_CLASSES))
VK_CLASSES_CPP = $(addsuffix .cpp, $(VM_CLASSES))
VK_SUPPORT_CPP = $(addsuffix .cpp, $(VM_SUPPORT))
VK_FAST_OBJS = $(addsuffix .o, $(VM_FAST))
VK_SLOW_OBJS = $(addsuffix .o, $(VM_SLOW))
VK_USER_OBJS = $(addsuffix .o, $(VM_USER_CLASSES))
# Note VM_GLOBAL_FAST and VM_GLOBAL_SLOW holds the files required from the
# run-time library. In practice everything is actually in VM_GLOBAL_FAST,
# but keeping the distinction for compatibility for now.
VK_GLOBAL_OBJS = $(addsuffix .o, $(VM_GLOBAL_FAST) $(VM_GLOBAL_SLOW))
ifneq ($(VM_PARALLEL_BUILDS),1)
# Fast building, all .cpp's in one fell swoop
# This saves about 5 sec per module, but can be slower if only a little changes
VK_OBJS += $(VM_PREFIX)__ALLcls.o $(VM_PREFIX)__ALLsup.o
all_cpp: $(VM_PREFIX)__ALLcls.cpp $(VM_PREFIX)__ALLsup.cpp
$(VM_PREFIX)__ALLcls.cpp: $(VK_CLASSES_CPP)
$(VERILATOR_INCLUDER) -DVL_INCLUDE_OPT=include $^ > $@
$(VM_PREFIX)__ALLsup.cpp: $(VK_SUPPORT_CPP)
# Fast build for small designs: All .cpp files in one fell swoop. This
# saves total compute, but can be slower if only a little changes. It is
# also a lot slower for medium to large designs when the speed of the C
# compiler dominates, which in this mode is not parallelizable.
VK_OBJS += $(VM_PREFIX)__ALL.o
$(VM_PREFIX)__ALL.cpp: $(addsuffix .cpp, $(VM_FAST) $(VM_SLOW))
$(VERILATOR_INCLUDER) -DVL_INCLUDE_OPT=include $^ > $@
all_cpp: $(VM_PREFIX)__ALL.cpp
else
#Slow way of building... Each .cpp file by itself
VK_OBJS += $(addsuffix .o, $(VM_CLASSES) $(VM_SUPPORT))
# Parallel build: Each .cpp file by itself. This can be somewhat slower for
# very small designs and examples, but is a lot faster for large designs.
VK_OBJS += $(VK_FAST_OBJS) $(VK_SLOW_OBJS)
endif
$(VM_PREFIX)__ALL.a: $(VK_OBJS)
$(AR) -cr $@ $^
$(RANLIB) $@
# When archiving just objects (.o), single $(AR) run is enough.
# When merging objects (.o) and archives (.a), the following steps are taken.
# 1. Extract object files from .a
# 2. Create a new archive from extracted .o and given .o
%.a:
@echo "Archive $(AR) -cr $@ $^"
@if test $(words $(filter %.a,$^)) -eq 0; then \
$(AR) -cr $@ $^; \
$(RANLIB) $@; \
else \
$(RM) -rf $*__tmpdir; \
for archive in $(filter %.a,$^); do \
mkdir -p $*__tmpdir/$$(basename $${archive}); \
cd $*__tmpdir/$$(basename $${archive}); \
$(AR) -x ../../$${archive}; \
cd ../..; \
done; \
$(AR) -cr $@ $(filter %.o,$^) $*__tmpdir/*/*.o; \
$(RM) -rf $*__tmpdir; \
fi
$(VM_PREFIX)__ALL.a: $(VK_OBJS) $(VM_HIER_LIBS)
######################################################################
### Compile rules
ifneq ($(VM_DEFAULT_RULES),0)
$(VM_PREFIX)__ALLcls.o: $(VM_PREFIX)__ALLcls.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<
$(VM_PREFIX)__ALLsup.o: $(VM_PREFIX)__ALLsup.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
# VM_GLOBAL_FAST files including verilated.o use this rule
# Anything not in $(VK_SLOW_OBJS) or $(VK_GLOBAL_OBJS), including verilated.o
# and user files passed on the Verilator command line use this rule.
%.o: %.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<
%__Slow.o: %__Slow.cpp
$(VK_SLOW_OBJS): %.o: %.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
$(VK_GLOBAL_OBJS): %.o: %.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_GLOBAL) -c -o $@ $<
endif
#Default rule embedded in make:
+1 -1
View File
@@ -4,7 +4,7 @@
//
//*************************************************************************
//
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
+3 -4
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -16,9 +16,8 @@
///
//*************************************************************************
///**** Product and Version name
// Autoconf substitutes this with the strings from AC_INIT.
#define VERILATOR_PRODUCT "@PACKAGE_NAME@"
#define VERILATOR_VERSION "@PACKAGE_VERSION@"
#define VERILATOR_PRODUCT "@PACKAGE_NAME@"
#define VERILATOR_VERSION "@PACKAGE_VERSION@"
+152 -147
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -29,7 +29,7 @@
// VerilatedCovImpBase
/// Implementation base class for constants
struct VerilatedCovImpBase {
struct VerilatedCovImpBase VL_NOT_FINAL {
// TYPES
enum { MAX_KEYS = 33 }; /// Maximum user arguments + filename+lineno
enum { KEY_UNDEF = 0 }; /// Magic key # for unspecified values
@@ -39,7 +39,7 @@ struct VerilatedCovImpBase {
// VerilatedCovImpItem
/// Implementation class for a VerilatedCov item
class VerilatedCovImpItem : VerilatedCovImpBase {
class VerilatedCovImpItem VL_NOT_FINAL : VerilatedCovImpBase {
public: // But only local to this file
// MEMBERS
int m_keys[MAX_KEYS]; ///< Key
@@ -47,12 +47,12 @@ public: // But only local to this file
// CONSTRUCTORS
// Derived classes should call zero() in their constructor
VerilatedCovImpItem() {
for (int i=0; i<MAX_KEYS; ++i) {
for (int i = 0; i < MAX_KEYS; ++i) {
m_keys[i] = KEY_UNDEF;
m_vals[i] = 0;
}
}
virtual ~VerilatedCovImpItem() {}
virtual ~VerilatedCovImpItem() = default;
virtual vluint64_t count() const = 0;
virtual void zero() const = 0;
};
@@ -63,19 +63,22 @@ public: // But only local to this file
/// This isn't in the header file for auto-magic conversion because it
/// inlines to too much code and makes compilation too slow.
template <class T> class VerilatedCoverItemSpec : public VerilatedCovImpItem {
template <class T> class VerilatedCoverItemSpec final : public VerilatedCovImpItem {
private:
// MEMBERS
T* m_countp; ///< Count value
T* m_countp; ///< Count value
public:
// METHODS
// cppcheck-suppress truncLongCastReturn
virtual vluint64_t count() const VL_OVERRIDE { return *m_countp; }
virtual void zero() const VL_OVERRIDE { *m_countp = 0; }
virtual vluint64_t count() const override { return *m_countp; }
virtual void zero() const override { *m_countp = 0; }
// CONSTRUCTORS
// cppcheck-suppress noExplicitConstructor
explicit VerilatedCoverItemSpec(T* countp) : m_countp(countp) { *m_countp = 0; }
virtual ~VerilatedCoverItemSpec() VL_OVERRIDE {}
explicit VerilatedCoverItemSpec(T* countp)
: m_countp{countp} {
*m_countp = 0;
}
virtual ~VerilatedCoverItemSpec() override = default;
};
//=============================================================================
@@ -84,31 +87,28 @@ public:
/// All value and keys are indexed into a unique number. Thus we can greatly reduce
/// the storage requirements for otherwise identical keys.
class VerilatedCovImp : VerilatedCovImpBase {
class VerilatedCovImp final : VerilatedCovImpBase {
private:
// TYPES
typedef std::map<std::string,int> ValueIndexMap;
typedef std::map<int,std::string> IndexValueMap;
typedef std::map<const std::string, int> ValueIndexMap;
typedef std::map<int, std::string> IndexValueMap;
typedef std::deque<VerilatedCovImpItem*> ItemList;
private:
// MEMBERS
VerilatedMutex m_mutex; ///< Protects all members, when VL_THREADED. Wrapper deals with setting it.
ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< For each key/value a unique arbitrary index value
IndexValueMap m_indexValues VL_GUARDED_BY(m_mutex); ///< For each key/value a unique arbitrary index value
ItemList m_items VL_GUARDED_BY(m_mutex); ///< List of all items
VerilatedMutex m_mutex; ///< Protects all members
ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for values
IndexValueMap m_indexValues VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for keys
ItemList m_items VL_GUARDED_BY(m_mutex); ///< List of all items
int m_nextIndex VL_GUARDED_BY(m_mutex) = (KEY_UNDEF + 1); ///< Next insert value
VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex); ///< Item about to insert
const char* m_insertFilenamep VL_GUARDED_BY(m_mutex); ///< Filename about to insert
int m_insertLineno VL_GUARDED_BY(m_mutex); ///< Line number about to insert
VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex) = nullptr; ///< Item about to insert
const char* m_insertFilenamep VL_GUARDED_BY(m_mutex) = nullptr; ///< Filename about to insert
int m_insertLineno VL_GUARDED_BY(m_mutex) = 0; ///< Line number about to insert
// CONSTRUCTORS
VerilatedCovImp() {
m_insertp = NULL;
m_insertFilenamep = NULL;
m_insertLineno = 0;
}
VerilatedCovImp() = default;
VL_UNCOPYABLE(VerilatedCovImp);
public:
~VerilatedCovImp() { clearGuts(); }
static VerilatedCovImp& imp() VL_MT_SAFE {
@@ -119,20 +119,21 @@ public:
private:
// PRIVATE METHODS
int valueIndex(const std::string& value) VL_REQUIRES(m_mutex) {
static int nextIndex = KEY_UNDEF+1;
ValueIndexMap::iterator iter = m_valueIndexes.find(value);
const auto iter = m_valueIndexes.find(value);
if (iter != m_valueIndexes.end()) return iter->second;
nextIndex++; assert(nextIndex>0);
m_valueIndexes.insert(std::make_pair(value, nextIndex));
m_indexValues.insert(std::make_pair(nextIndex, value));
return nextIndex;
m_nextIndex++;
assert(m_nextIndex > 0); // Didn't rollover
m_valueIndexes.emplace(value, m_nextIndex);
m_indexValues.emplace(m_nextIndex, value);
return m_nextIndex;
}
static std::string dequote(const std::string& text) VL_PURE {
// Quote any special characters
std::string rtn;
for (const char* pos = text.c_str(); *pos; ++pos) {
if (!isprint(*pos) || *pos=='%' || *pos=='"') {
char hex[10]; sprintf(hex, "%%%02X", pos[0]);
if (!isprint(*pos) || *pos == '%' || *pos == '"') {
char hex[10];
sprintf(hex, "%%%02X", pos[0]);
rtn += hex;
} else {
rtn += *pos;
@@ -145,18 +146,19 @@ private:
// don't want applications to either get confused if they use
// a letter differently, nor want them to rely on our compression...
// (Considered using numeric keys, but will remain back compatible.)
if (key.length()<2) return false;
if (key.length()==2 && isdigit(key[1])) return false;
if (key.length() < 2) return false;
if (key.length() == 2 && isdigit(key[1])) return false;
return true;
}
static std::string keyValueFormatter(const std::string& key, const std::string& value) VL_PURE {
static std::string keyValueFormatter(const std::string& key,
const std::string& value) VL_PURE {
std::string name;
if (key.length()==1 && isalpha(key[0])) {
name += std::string("\001")+key;
if (key.length() == 1 && isalpha(key[0])) {
name += std::string("\001") + key;
} else {
name += std::string("\001")+dequote(key);
name += std::string("\001") + dequote(key);
}
name += std::string("\002")+dequote(value);
name += std::string("\002") + dequote(value);
return name;
}
static std::string combineHier(const std::string& old, const std::string& add) VL_PURE {
@@ -173,28 +175,35 @@ private:
// Scan forward to first mismatch
const char* apre = a;
const char* bpre = b;
while (*apre == *bpre) { apre++; bpre++; }
while (*apre == *bpre) {
apre++;
bpre++;
}
// We used to backup and split on only .'s but it seems better to be verbose
// and not assume . is the separator
std::string prefix = std::string(a, apre-a);
std::string prefix = std::string(a, apre - a);
// Scan backward to last mismatch
const char* apost = a+strlen(a)-1;
const char* bpost = b+strlen(b)-1;
while (*apost == *bpost
&& apost>apre && bpost>bpre) { apost--; bpost--; }
const char* apost = a + strlen(a) - 1;
const char* bpost = b + strlen(b) - 1;
while (*apost == *bpost && apost > apre && bpost > bpre) {
apost--;
bpost--;
}
// Forward to . so we have a whole word
std::string suffix = *bpost ? std::string(bpost+1) : "";
std::string suffix = *bpost ? std::string(bpost + 1) : "";
std::string out = prefix+"*"+suffix;
std::string out = prefix + "*" + suffix;
//cout << "\nch pre="<<prefix<<" s="<<suffix<<"\nch a="<<old<<"\nch b="<<add<<"\nch o="<<out<<endl;
// cout << "\nch pre="<<prefix<<" s="<<suffix<<"\nch a="<<old<<"\nch b="<<add
// <<"\ncho="<<out<<endl;
return out;
}
bool itemMatchesString(VerilatedCovImpItem* itemp, const std::string& match) VL_REQUIRES(m_mutex) {
for (int i=0; i<MAX_KEYS; ++i) {
bool itemMatchesString(VerilatedCovImpItem* itemp, const std::string& match)
VL_REQUIRES(m_mutex) {
for (int i = 0; i < MAX_KEYS; ++i) {
if (itemp->m_keys[i] != KEY_UNDEF) {
// We don't compare keys, only values
std::string val = m_indexValues[itemp->m_vals[i]];
@@ -207,39 +216,41 @@ private:
}
static void selftest() VL_MT_SAFE {
// Little selftest
if (combineHier("a.b.c","a.b.c") !="a.b.c") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("a.b.c","a.b") !="a.b*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("a.x.c","a.y.c") !="a.*.c") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("a.z.z.z.c","a.b.c") !="a.*.c") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("z","a") !="*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("q.a","q.b") !="q.*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("q.za","q.zb") !="q.z*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier("1.2.3.a","9.8.7.a") !="*.a") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
#define SELF_CHECK(got, exp) \
do { \
if ((got) != (exp)) VL_FATAL_MT(__FILE__, __LINE__, "", "%Error: selftest\n"); \
} while (0)
SELF_CHECK(combineHier("a.b.c", "a.b.c"), "a.b.c");
SELF_CHECK(combineHier("a.b.c", "a.b"), "a.b*");
SELF_CHECK(combineHier("a.x.c", "a.y.c"), "a.*.c");
SELF_CHECK(combineHier("a.z.z.z.c", "a.b.c"), "a.*.c");
SELF_CHECK(combineHier("z", "a"), "*");
SELF_CHECK(combineHier("q.a", "q.b"), "q.*");
SELF_CHECK(combineHier("q.za", "q.zb"), "q.z*");
SELF_CHECK(combineHier("1.2.3.a", "9.8.7.a"), "*.a");
#undef SELF_CHECK
}
void clearGuts() VL_REQUIRES(m_mutex) {
for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) {
VerilatedCovImpItem* itemp = *(it);
VL_DO_DANGLING(delete itemp, itemp);
}
for (const auto& itemp : m_items) VL_DO_DANGLING(delete itemp, itemp);
m_items.clear();
m_indexValues.clear();
m_valueIndexes.clear();
m_nextIndex = KEY_UNDEF + 1;
}
public:
// PUBLIC METHODS
void clear() VL_EXCLUDES(m_mutex) {
Verilated::quiesce();
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
clearGuts();
}
void clearNonMatch(const char* matchp) VL_EXCLUDES(m_mutex) {
Verilated::quiesce();
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
if (matchp && matchp[0]) {
ItemList newlist;
for (ItemList::iterator it=m_items.begin(); it!=m_items.end(); ++it) {
VerilatedCovImpItem* itemp = *(it);
for (const auto& itemp : m_items) {
if (!itemMatchesString(itemp, matchp)) {
VL_DO_DANGLING(delete itemp, itemp);
} else {
@@ -251,50 +262,48 @@ public:
}
void zero() VL_EXCLUDES(m_mutex) {
Verilated::quiesce();
VerilatedLockGuard lock(m_mutex);
for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) {
(*it)->zero();
}
const VerilatedLockGuard lock(m_mutex);
for (const auto& itemp : m_items) itemp->zero();
}
// We assume there's always call to i/f/p in that order
void inserti(VerilatedCovImpItem* itemp) VL_EXCLUDES(m_mutex) {
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
assert(!m_insertp);
m_insertp = itemp;
}
void insertf(const char* filenamep, int lineno) VL_EXCLUDES(m_mutex) {
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
m_insertFilenamep = filenamep;
m_insertLineno = lineno;
}
void insertp(const char* ckeyps[MAX_KEYS],
const char* valps[MAX_KEYS]) VL_EXCLUDES(m_mutex) {
VerilatedLockGuard lock(m_mutex);
void insertp(const char* ckeyps[MAX_KEYS], const char* valps[MAX_KEYS]) VL_EXCLUDES(m_mutex) {
const VerilatedLockGuard lock(m_mutex);
assert(m_insertp);
// First two key/vals are filename
ckeyps[0]="filename"; valps[0]=m_insertFilenamep;
ckeyps[0] = "filename";
valps[0] = m_insertFilenamep;
std::string linestr = vlCovCvtToStr(m_insertLineno);
ckeyps[1]="lineno"; valps[1]=linestr.c_str();
ckeyps[1] = "lineno";
valps[1] = linestr.c_str();
// Default page if not specified
const char* fnstartp = m_insertFilenamep;
while (const char* foundp = strchr(fnstartp,'/')) fnstartp = foundp+1;
while (const char* foundp = strchr(fnstartp, '/')) fnstartp = foundp + 1;
const char* fnendp = fnstartp;
while (*fnendp && *fnendp!='.') fnendp++;
std::string page_default = "sp_user/"+std::string(fnstartp, fnendp-fnstartp);
ckeyps[2]="page"; valps[2]=page_default.c_str();
for (; *fnendp && *fnendp != '.'; fnendp++) {}
std::string page_default = "sp_user/" + std::string(fnstartp, fnendp - fnstartp);
ckeyps[2] = "page";
valps[2] = page_default.c_str();
// Keys -> strings
std::string keys[MAX_KEYS];
for (int i=0; i<MAX_KEYS; ++i) {
if (ckeyps[i] && ckeyps[i][0]) {
keys[i] = ckeyps[i];
}
for (int i = 0; i < MAX_KEYS; ++i) {
if (ckeyps[i] && ckeyps[i][0]) { keys[i] = ckeyps[i]; }
}
// Ignore empty keys
for (int i=0; i<MAX_KEYS; ++i) {
for (int i = 0; i < MAX_KEYS; ++i) {
if (!keys[i].empty()) {
for (int j=i+1; j<MAX_KEYS; ++j) {
for (int j = i + 1; j < MAX_KEYS; ++j) {
if (keys[i] == keys[j]) { // Duplicate key. Keep the last one
keys[i] = "";
break;
@@ -304,30 +313,30 @@ public:
}
// Insert the values
int addKeynum = 0;
for (int i=0; i<MAX_KEYS; ++i) {
for (int i = 0; i < MAX_KEYS; ++i) {
const std::string key = keys[i];
if (!keys[i].empty()) {
const std::string val = valps[i];
//cout<<" "<<__FUNCTION__<<" "<<key<<" = "<<val<<endl;
// cout<<" "<<__FUNCTION__<<" "<<key<<" = "<<val<<endl;
m_insertp->m_keys[addKeynum] = valueIndex(key);
m_insertp->m_vals[addKeynum] = valueIndex(val);
addKeynum++;
if (!legalKey(key)) {
if (VL_UNCOVERABLE(!legalKey(key))) {
std::string msg
= ("%Error: Coverage keys of one character, or letter+digit are illegal: "
+key);
+ key); // LCOV_EXCL_LINE
VL_FATAL_MT("", 0, "", msg.c_str());
}
}
}
m_items.push_back(m_insertp);
// Prepare for next
m_insertp = NULL;
m_insertp = nullptr;
}
void write(const char* filename) VL_EXCLUDES(m_mutex) {
Verilated::quiesce();
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
#ifndef VM_COVERAGE
VL_FATAL_MT("", 0, "", "%Error: Called VerilatedCov::write when VM_COVERAGE disabled\n");
#endif
@@ -335,22 +344,21 @@ public:
std::ofstream os(filename);
if (os.fail()) {
std::string msg = std::string("%Error: Can't write '")+filename+"'";
std::string msg = std::string("%Error: Can't write '") + filename + "'";
VL_FATAL_MT("", 0, "", msg.c_str());
return;
}
os << "# SystemC::Coverage-3\n";
// Build list of events; totalize if collapsing hierarchy
typedef std::map<std::string,std::pair<std::string,vluint64_t> > EventMap;
typedef std::map<const std::string, std::pair<std::string, vluint64_t>> EventMap;
EventMap eventCounts;
for (ItemList::iterator it=m_items.begin(); it!=m_items.end(); ++it) {
VerilatedCovImpItem* itemp = *(it);
for (const auto& itemp : m_items) {
std::string name;
std::string hier;
bool per_instance = false;
for (int i=0; i<MAX_KEYS; ++i) {
for (int i = 0; i < MAX_KEYS; ++i) {
if (itemp->m_keys[i] != KEY_UNDEF) {
std::string key = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]);
std::string val = m_indexValues[itemp->m_vals[i]];
@@ -376,23 +384,23 @@ public:
// inefficient)
// Find or insert the named event
EventMap::iterator cit = eventCounts.find(name);
const auto cit = eventCounts.find(name);
if (cit != eventCounts.end()) {
const std::string& oldhier = cit->second.first;
cit->second.second += itemp->count();
cit->second.first = combineHier(oldhier, hier);
cit->second.first = combineHier(oldhier, hier);
} else {
eventCounts.insert(std::make_pair(name, make_pair(hier, itemp->count())));
eventCounts.emplace(name, make_pair(hier, itemp->count()));
}
}
// Output body
for (EventMap::const_iterator it=eventCounts.begin(); it!=eventCounts.end(); ++it) {
os<<"C '"<<std::dec;
os<<it->first;
if (!it->second.first.empty()) os<<keyValueFormatter(VL_CIK_HIER, it->second.first);
os<<"' "<<it->second.second;
os<<std::endl;
for (const auto& i : eventCounts) {
os << "C '" << std::dec;
os << i.first;
if (!i.second.first.empty()) os << keyValueFormatter(VL_CIK_HIER, i.second.first);
os << "' " << i.second.second;
os << '\n';
}
}
};
@@ -400,15 +408,11 @@ public:
//=============================================================================
// VerilatedCov
void VerilatedCov::clear() VL_MT_SAFE {
VerilatedCovImp::imp().clear();
}
void VerilatedCov::clear() VL_MT_SAFE { VerilatedCovImp::imp().clear(); }
void VerilatedCov::clearNonMatch(const char* matchp) VL_MT_SAFE {
VerilatedCovImp::imp().clearNonMatch(matchp);
}
void VerilatedCov::zero() VL_MT_SAFE {
VerilatedCovImp::imp().zero();
}
void VerilatedCov::zero() VL_MT_SAFE { VerilatedCovImp::imp().zero(); }
void VerilatedCov::write(const char* filenamep) VL_MT_SAFE {
VerilatedCovImp::imp().write(filenamep);
}
@@ -422,48 +426,49 @@ void VerilatedCov::_insertf(const char* filename, int lineno) VL_MT_SAFE {
VerilatedCovImp::imp().insertf(filename, lineno);
}
#define K(n) const char* key ## n
#define A(n) const char* key ## n, const char* valp ## n // Argument list
#define C(n) key ## n, valp ## n // Calling argument list
#define N(n) "","" // Null argument list
void VerilatedCov::_insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9),
A(10),A(11),A(12),A(13),A(14),A(15),A(16),A(17),A(18),A(19),
A(20),A(21),A(22),A(23),A(24),A(25),A(26),A(27),A(28),A(29)) VL_MT_SAFE {
#define K(n) const char* key##n
#define A(n) const char *key##n, const char *valp##n // Argument list
#define C(n) key##n, valp##n // Calling argument list
#define N(n) "", "" // Null argument list
void VerilatedCov::_insertp(A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19), A(20),
A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
A(29)) VL_MT_SAFE {
const char* keyps[VerilatedCovImpBase::MAX_KEYS]
= {NULL,NULL,NULL, // filename,lineno,page
key0,key1,key2,key3,key4,key5,key6,key7,key8,key9,
key10,key11,key12,key13,key14,key15,key16,key17,key18,key19,
key20,key21,key22,key23,key24,key25,key26,key27,key28,key29};
= {nullptr, nullptr, nullptr, // filename,lineno,page
key0, key1, key2, key3, key4, key5, key6, key7, key8, key9,
key10, key11, key12, key13, key14, key15, key16, key17, key18, key19,
key20, key21, key22, key23, key24, key25, key26, key27, key28, key29};
const char* valps[VerilatedCovImpBase::MAX_KEYS]
= {NULL,NULL,NULL, // filename,lineno,page
valp0,valp1,valp2,valp3,valp4,valp5,valp6,valp7,valp8,valp9,
valp10,valp11,valp12,valp13,valp14,valp15,valp16,valp17,valp18,valp19,
valp20,valp21,valp22,valp23,valp24,valp25,valp26,valp27,valp28,valp29};
= {nullptr, nullptr, nullptr, // filename,lineno,page
valp0, valp1, valp2, valp3, valp4, valp5, valp6, valp7, valp8, valp9,
valp10, valp11, valp12, valp13, valp14, valp15, valp16, valp17, valp18, valp19,
valp20, valp21, valp22, valp23, valp24, valp25, valp26, valp27, valp28, valp29};
VerilatedCovImp::imp().insertp(keyps, valps);
}
// And versions with fewer arguments (oh for a language with named parameters!)
void VerilatedCov::_insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)) VL_MT_SAFE {
_insertp(C(0),C(1),C(2),C(3),C(4),C(5),C(6),C(7),C(8),C(9),
N(10),N(11),N(12),N(13),N(14),N(15),N(16),N(17),N(18),N(19),
N(20),N(21),N(22),N(23),N(24),N(25),N(26),N(27),N(28),N(29));
void VerilatedCov::_insertp(A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8),
A(9)) VL_MT_SAFE {
_insertp(C(0), C(1), C(2), C(3), C(4), C(5), C(6), C(7), C(8), C(9), N(10), N(11), N(12),
N(13), N(14), N(15), N(16), N(17), N(18), N(19), N(20), N(21), N(22), N(23), N(24),
N(25), N(26), N(27), N(28), N(29));
}
void VerilatedCov::_insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9),
A(10),A(11),A(12),A(13),A(14),A(15),A(16),A(17),A(18),A(19)) VL_MT_SAFE {
_insertp(C(0),C(1),C(2),C(3),C(4),C(5),C(6),C(7),C(8),C(9),
C(10),C(11),C(12),C(13),C(14),C(15),C(16),C(17),C(18),C(19),
N(20),N(21),N(22),N(23),N(24),N(25),N(26),N(27),N(28),N(29));
void VerilatedCov::_insertp(A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
A(19)) VL_MT_SAFE {
_insertp(C(0), C(1), C(2), C(3), C(4), C(5), C(6), C(7), C(8), C(9), C(10), C(11), C(12),
C(13), C(14), C(15), C(16), C(17), C(18), C(19), N(20), N(21), N(22), N(23), N(24),
N(25), N(26), N(27), N(28), N(29));
}
// Backward compatibility for Verilator
void VerilatedCov::_insertp(A(0), A(1), K(2),int val2, K(3),int val3,
K(4),const std::string& val4, A(5),A(6)) VL_MT_SAFE {
void VerilatedCov::_insertp(A(0), A(1), K(2), int val2, K(3), int val3, K(4),
const std::string& val4, A(5), A(6), A(7)) VL_MT_SAFE {
std::string val2str = vlCovCvtToStr(val2);
std::string val3str = vlCovCvtToStr(val3);
_insertp(C(0),C(1),
key2,val2str.c_str(), key3,val3str.c_str(), key4, val4.c_str(),
C(5),C(6),N(7),N(8),N(9),
N(10),N(11),N(12),N(13),N(14),N(15),N(16),N(17),N(18),N(19),
N(20),N(21),N(22),N(23),N(24),N(25),N(26),N(27),N(28),N(29));
_insertp(C(0), C(1), key2, val2str.c_str(), key3, val3str.c_str(), key4, val4.c_str(), C(5),
C(6), C(7), N(8), N(9), N(10), N(11), N(12), N(13), N(14), N(15), N(16), N(17), N(18),
N(19), N(20), N(21), N(22), N(23), N(24), N(25), N(26), N(27), N(28), N(29));
}
#undef A
#undef C
+23 -21
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -28,17 +28,17 @@
//=============================================================================
/// Conditionally compile coverage code
// clang-format off
#ifdef VM_COVERAGE
# define VL_IF_COVER(stmts) \
do { \
stmts; \
} while (false)
do { stmts; } while (false)
#else
# define VL_IF_COVER(stmts) \
do { \
if (false) { stmts; } \
} while (false)
#endif
// clang-format on
//=============================================================================
/// Insert a item for coverage analysis.
@@ -68,16 +68,17 @@
/// VL_COVER_INSERT(&m_cases[i], "comment", "Coverage Case", "i", cvtToNumStr(i));
/// }
#define VL_COVER_INSERT(countp,...) \
VL_IF_COVER(VerilatedCov::_inserti(countp); \
VerilatedCov::_insertf(__FILE__, __LINE__); \
#define VL_COVER_INSERT(countp, ...) \
VL_IF_COVER(VerilatedCov::_inserti(countp); VerilatedCov::_insertf(__FILE__, __LINE__); \
VerilatedCov::_insertp("hier", name(), __VA_ARGS__))
//=============================================================================
/// Convert VL_COVER_INSERT value arguments to strings
template< class T> std::string vlCovCvtToStr(const T& t) VL_PURE {
std::ostringstream os; os<<t; return os.str();
template <class T> std::string vlCovCvtToStr(const T& t) VL_PURE {
std::ostringstream os;
os << t;
return os.str();
}
//=============================================================================
@@ -87,8 +88,9 @@ template< class T> std::string vlCovCvtToStr(const T& t) VL_PURE {
/// Global class with methods affecting all coverage data.
/// All public methods in this class are thread safe.
class VerilatedCov {
class VerilatedCov final {
VL_UNCOPYABLE(VerilatedCov);
public:
// GLOBAL METHODS
/// Return default filename
@@ -108,18 +110,18 @@ public:
// We could have just the maximum argument version, but this compiles
// much slower (nearly 2x) than having smaller versions also. However
// there's not much more gain in having a version for each number of args.
#define K(n) const char* key ## n
#define A(n) const char* key ## n, const char* valp ## n // Argument list
#define D(n) const char* key ## n = NULL, const char* valp ## n = NULL // Argument list
static void _insertp(D(0),D(1),D(2),D(3),D(4),D(5),D(6),D(7),D(8),D(9));
static void _insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)
,A(10),D(11),D(12),D(13),D(14),D(15),D(16),D(17),D(18),D(19));
static void _insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)
,A(10),A(11),A(12),A(13),A(14),A(15),A(16),A(17),A(18),A(19)
,A(20),D(21),D(22),D(23),D(24),D(25),D(26),D(27),D(28),D(29));
#define K(n) const char* key##n
#define A(n) const char *key##n, const char *valp##n // Argument list
#define D(n) const char *key##n = nullptr, const char *valp##n = nullptr // Argument list
static void _insertp(D(0), D(1), D(2), D(3), D(4), D(5), D(6), D(7), D(8), D(9));
static void _insertp(A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10), D(11),
D(12), D(13), D(14), D(15), D(16), D(17), D(18), D(19));
static void _insertp(A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10), A(11),
A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19), A(20), D(21),
D(22), D(23), D(24), D(25), D(26), D(27), D(28), D(29));
// Backward compatibility for Verilator
static void _insertp(A(0), A(1), K(2),int val2, K(3),int val3,
K(4),const std::string& val4, A(5),A(6));
static void _insertp(A(0), A(1), K(2), int val2, K(3), int val3, K(4), const std::string& val4,
A(5), A(6), A(7));
#undef K
#undef A
+16 -74
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -28,66 +28,28 @@
#define VLCOVGEN_ITEM(string_parsed_by_vlcovgen)
VLCOVGEN_ITEM("name=>'col0_name', short=>'C0', group=>1, default=>undef, descr=>'The column title for the header line of this column'")
VLCOVGEN_ITEM("name=>'col1_name', short=>'C1', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'col2_name', short=>'C2', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'col3_name', short=>'C3', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'column', short=>'n', group=>1, default=>0, descr=>'Column number for the item. Used to disambiguate multiple coverage points on the same line number'")
VLCOVGEN_ITEM("name=>'filename', short=>'f', group=>1, default=>undef, descr=>'Filename of the item'")
VLCOVGEN_ITEM("name=>'groupdesc', short=>'d', group=>1, default=>'', descr=>'Description of the covergroup this item belongs to'")
VLCOVGEN_ITEM("name=>'groupname', short=>'g', group=>1, default=>'', descr=>'Group name of the covergroup this item belongs to'")
VLCOVGEN_ITEM("name=>'groupcmt', short=>'O', group=>1, default=>'', ")
VLCOVGEN_ITEM("name=>'per_instance',short=>'P', group=>1, default=>0, descr=>'True if every hierarchy is independently counted; otherwise all hierarchies will be combined into a single count'")
VLCOVGEN_ITEM("name=>'row0_name', short=>'R0', group=>1, default=>undef, descr=>'The row title for the header line of this row'")
VLCOVGEN_ITEM("name=>'row1_name', short=>'R1', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'row2_name', short=>'R2', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'row3_name', short=>'R3', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'table', short=>'T', group=>1, default=>undef, descr=>'The name of the table for automatically generated tables'")
VLCOVGEN_ITEM("name=>'thresh', short=>'s', group=>1, default=>undef, ")
VLCOVGEN_ITEM("name=>'type', short=>'t', group=>1, default=>'', descr=>'Type of coverage (block, line, fsm, etc)'")
// clang-format off
VLCOVGEN_ITEM("'name':'column', 'short':'n', 'group':1, 'default':0, 'descr':'Column number for the item. Used to disambiguate multiple coverage points on the same line number'")
VLCOVGEN_ITEM("'name':'filename', 'short':'f', 'group':1, 'default':None, 'descr':'Filename of the item'")
VLCOVGEN_ITEM("'name':'linescov', 'short':'S', 'group':1, 'default':'', 'descr':'List of comma-separated lines covered'")
VLCOVGEN_ITEM("'name':'per_instance','short':'P', 'group':1, 'default':0, 'descr':'True if every hierarchy is independently counted; otherwise all hierarchies will be combined into a single count'")
VLCOVGEN_ITEM("'name':'thresh', 'short':'s', 'group':1, 'default':None, 'descr':'Number of hits to consider covered (aka at_least)'")
VLCOVGEN_ITEM("'name':'type', 'short':'t', 'group':1, 'default':'', 'descr':'Type of coverage (block, line, fsm, etc)'")
// Bin attributes
VLCOVGEN_ITEM("name=>'col0', short=>'c0', group=>0, default=>undef, descr=>'The (enumeration) value name for this column in a table cross' ")
VLCOVGEN_ITEM("name=>'col1', short=>'c1', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'col2', short=>'c2', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'col3', short=>'c3', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'comment', short=>'o', group=>0, default=>'', descr=>'Textual description for the item'")
VLCOVGEN_ITEM("name=>'hier', short=>'h', group=>0, default=>'', descr=>'Hierarchy path name for the item'")
VLCOVGEN_ITEM("name=>'limit', short=>'L', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'lineno', short=>'l', group=>0, default=>0, descr=>'Line number for the item'")
VLCOVGEN_ITEM("name=>'row0', short=>'r0', group=>0, default=>undef, descr=>'The (enumeration) value name for this row in a table cross'")
VLCOVGEN_ITEM("name=>'row1', short=>'r1', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'row2', short=>'r2', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'row3', short=>'r3', group=>0, default=>undef, ")
VLCOVGEN_ITEM("name=>'weight', short=>'w', group=>0, default=>undef, descr=>'For totaling items, weight of this item'")
VLCOVGEN_ITEM("'name':'comment', 'short':'o', 'group':0, 'default':'', 'descr':'Textual description for the item'")
VLCOVGEN_ITEM("'name':'hier', 'short':'h', 'group':0, 'default':'', 'descr':'Hierarchy path name for the item'")
VLCOVGEN_ITEM("'name':'lineno', 'short':'l', 'group':0, 'default':0, 'descr':'Line number for the item'")
VLCOVGEN_ITEM("'name':'weight', 'short':'w', 'group':0, 'default':None, 'descr':'For totaling items, weight of this item'")
// clang-format on
// VLCOVGEN_CIK_AUTO_EDIT_BEGIN
#define VL_CIK_COL0 "c0"
#define VL_CIK_COL0_NAME "C0"
#define VL_CIK_COL1 "c1"
#define VL_CIK_COL1_NAME "C1"
#define VL_CIK_COL2 "c2"
#define VL_CIK_COL2_NAME "C2"
#define VL_CIK_COL3 "c3"
#define VL_CIK_COL3_NAME "C3"
#define VL_CIK_COLUMN "n"
#define VL_CIK_COMMENT "o"
#define VL_CIK_FILENAME "f"
#define VL_CIK_GROUPCMT "O"
#define VL_CIK_GROUPDESC "d"
#define VL_CIK_GROUPNAME "g"
#define VL_CIK_HIER "h"
#define VL_CIK_LIMIT "L"
#define VL_CIK_LINENO "l"
#define VL_CIK_LINESCOV "S"
#define VL_CIK_PER_INSTANCE "P"
#define VL_CIK_ROW0 "r0"
#define VL_CIK_ROW0_NAME "R0"
#define VL_CIK_ROW1 "r1"
#define VL_CIK_ROW1_NAME "R1"
#define VL_CIK_ROW2 "r2"
#define VL_CIK_ROW2_NAME "R2"
#define VL_CIK_ROW3 "r3"
#define VL_CIK_ROW3_NAME "R3"
#define VL_CIK_TABLE "T"
#define VL_CIK_THRESH "s"
#define VL_CIK_TYPE "t"
#define VL_CIK_WEIGHT "w"
@@ -98,37 +60,17 @@ VLCOVGEN_ITEM("name=>'weight', short=>'w', group=>0, default=>undef, descr
/// Verilator coverage global class.
/// This class is thread safe.
class VerilatedCovKey {
class VerilatedCovKey final {
public:
static std::string shortKey(const std::string& key) VL_PURE {
// VLCOVGEN_SHORT_AUTO_EDIT_BEGIN
if (key == "col0") return VL_CIK_COL0;
if (key == "col0_name") return VL_CIK_COL0_NAME;
if (key == "col1") return VL_CIK_COL1;
if (key == "col1_name") return VL_CIK_COL1_NAME;
if (key == "col2") return VL_CIK_COL2;
if (key == "col2_name") return VL_CIK_COL2_NAME;
if (key == "col3") return VL_CIK_COL3;
if (key == "col3_name") return VL_CIK_COL3_NAME;
if (key == "column") return VL_CIK_COLUMN;
if (key == "comment") return VL_CIK_COMMENT;
if (key == "filename") return VL_CIK_FILENAME;
if (key == "groupcmt") return VL_CIK_GROUPCMT;
if (key == "groupdesc") return VL_CIK_GROUPDESC;
if (key == "groupname") return VL_CIK_GROUPNAME;
if (key == "hier") return VL_CIK_HIER;
if (key == "limit") return VL_CIK_LIMIT;
if (key == "lineno") return VL_CIK_LINENO;
if (key == "linescov") return VL_CIK_LINESCOV;
if (key == "per_instance") return VL_CIK_PER_INSTANCE;
if (key == "row0") return VL_CIK_ROW0;
if (key == "row0_name") return VL_CIK_ROW0_NAME;
if (key == "row1") return VL_CIK_ROW1;
if (key == "row1_name") return VL_CIK_ROW1_NAME;
if (key == "row2") return VL_CIK_ROW2;
if (key == "row2_name") return VL_CIK_ROW2_NAME;
if (key == "row3") return VL_CIK_ROW3;
if (key == "row3_name") return VL_CIK_ROW3_NAME;
if (key == "table") return VL_CIK_TABLE;
if (key == "thresh") return VL_CIK_THRESH;
if (key == "type") return VL_CIK_TYPE;
if (key == "weight") return VL_CIK_WEIGHT;
+294 -291
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2009-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -37,91 +37,78 @@
//======================================================================
// Internal macros
// Not supported yet
#define _VL_SVDPI_UNIMP() \
VL_FATAL_MT(__FILE__, __LINE__, "", \
(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
#define _VL_SVDPI_WARN(...) \
VL_PRINTF_MT(__VA_ARGS__)
#define _VL_SVDPI_WARN(...) VL_PRINTF_MT(__VA_ARGS__)
// Function requires a "context" in the import declaration
#define _VL_SVDPI_CONTEXT_WARN() \
_VL_SVDPI_WARN("%%Warning: DPI C Function called by Verilog DPI import with missing 'context' keyword.\n");
_VL_SVDPI_WARN("%%Warning: DPI C Function called by Verilog DPI import with missing " \
"'context' keyword.\n")
//======================================================================
//======================================================================
//======================================================================
// DPI ROUTINES
const char* svDpiVersion() {
return "1800-2005";
}
const char* svDpiVersion() { return "1800-2005"; }
//======================================================================
// Bit-select utility functions.
svBit svGetBitselBit(const svBitVecVal* sp, int bit) {
return VL_BITRSHIFT_W(sp,bit) & 1;
}
svBit svGetBitselBit(const svBitVecVal* sp, int bit) { return VL_BITRSHIFT_W(sp, bit) & 1; }
svLogic svGetBitselLogic(const svLogicVecVal* sp, int bit) {
// Not VL_BITRSHIFT_W as sp is a different structure type
// Verilator doesn't support X/Z so only aval
return (((sp[VL_BITWORD_I(bit)].aval >> VL_BITBIT_I(bit)) & 1)
| (((sp[VL_BITWORD_I(bit)].bval >> VL_BITBIT_I(bit)) & 1)<<1));
| (((sp[VL_BITWORD_I(bit)].bval >> VL_BITBIT_I(bit)) & 1) << 1));
}
void svPutBitselBit(svBitVecVal* dp, int bit, svBit s) {
VL_ASSIGNBIT_WI(32, bit, dp, s);
}
void svPutBitselBit(svBitVecVal* dp, int bit, svBit s) { VL_ASSIGNBIT_WI(32, bit, dp, s); }
void svPutBitselLogic(svLogicVecVal* dp, int bit, svLogic s) {
// Verilator doesn't support X/Z so only aval
dp[VL_BITWORD_I(bit)].aval
= ((dp[VL_BITWORD_I(bit)].aval & ~(VL_UL(1)<<VL_BITBIT_I(bit)))
| ((s&1)<<VL_BITBIT_I(bit)));
dp[VL_BITWORD_I(bit)].bval
= ((dp[VL_BITWORD_I(bit)].bval & ~(VL_UL(1)<<VL_BITBIT_I(bit)))
| ((s&2)>>1<<VL_BITBIT_I(bit)));
dp[VL_BITWORD_I(bit)].aval = ((dp[VL_BITWORD_I(bit)].aval & ~(VL_UL(1) << VL_BITBIT_I(bit)))
| ((s & 1) << VL_BITBIT_I(bit)));
dp[VL_BITWORD_I(bit)].bval = ((dp[VL_BITWORD_I(bit)].bval & ~(VL_UL(1) << VL_BITBIT_I(bit)))
| ((s & 2) >> 1 << VL_BITBIT_I(bit)));
}
void svGetPartselBit(svBitVecVal* dp, const svBitVecVal* sp, int lsb, int width) {
// See also VL_SEL_WWI
int msb = lsb+width-1;
int msb = lsb + width - 1;
int word_shift = VL_BITWORD_I(lsb);
if (VL_BITBIT_I(lsb)==0) {
if (VL_BITBIT_I(lsb) == 0) {
// Just a word extract
for (int i=0; i<VL_WORDS_I(width); ++i) dp[i] = sp[i+word_shift];
for (int i = 0; i < VL_WORDS_I(width); ++i) dp[i] = sp[i + word_shift];
} else {
int loffset = lsb & VL_SIZEBITS_I;
int nbitsfromlow = 32-loffset; // bits that end up in lword (know loffset!=0)
int nbitsfromlow = 32 - loffset; // bits that end up in lword (know loffset!=0)
// Middle words
int words = VL_WORDS_I(msb-lsb+1);
for (int i=0; i<words; ++i) {
dp[i] = sp[i+word_shift]>>loffset;
int upperword = i+word_shift+1;
int words = VL_WORDS_I(msb - lsb + 1);
for (int i = 0; i < words; ++i) {
dp[i] = sp[i + word_shift] >> loffset;
int upperword = i + word_shift + 1;
if (upperword <= static_cast<int>(VL_BITWORD_I(msb))) {
dp[i] |= sp[upperword] << nbitsfromlow;
}
}
}
// Clean result
dp[VL_WORDS_I(width)-1] &= VL_MASK_I(width);
dp[VL_WORDS_I(width) - 1] &= VL_MASK_I(width);
}
void svGetPartselLogic(svLogicVecVal* dp, const svLogicVecVal* sp, int lsb, int width) {
int msb = lsb+width-1;
int msb = lsb + width - 1;
int word_shift = VL_BITWORD_I(lsb);
if (VL_BITBIT_I(lsb)==0) {
if (VL_BITBIT_I(lsb) == 0) {
// Just a word extract
for (int i=0; i<VL_WORDS_I(width); ++i) dp[i] = sp[i+word_shift];
for (int i = 0; i < VL_WORDS_I(width); ++i) dp[i] = sp[i + word_shift];
} else {
int loffset = lsb & VL_SIZEBITS_I;
int nbitsfromlow = 32-loffset; // bits that end up in lword (know loffset!=0)
int nbitsfromlow = 32 - loffset; // bits that end up in lword (know loffset!=0)
// Middle words
int words = VL_WORDS_I(msb-lsb+1);
for (int i=0; i<words; ++i) {
dp[i].aval = sp[i+word_shift].aval >> loffset;
dp[i].bval = sp[i+word_shift].bval >> loffset;
int upperword = i+word_shift+1;
int words = VL_WORDS_I(msb - lsb + 1);
for (int i = 0; i < words; ++i) {
dp[i].aval = sp[i + word_shift].aval >> loffset;
dp[i].bval = sp[i + word_shift].bval >> loffset;
int upperword = i + word_shift + 1;
if (upperword <= static_cast<int>(VL_BITWORD_I(msb))) {
dp[i].aval |= sp[upperword].aval << nbitsfromlow;
dp[i].bval |= sp[upperword].bval << nbitsfromlow;
@@ -129,58 +116,56 @@ void svGetPartselLogic(svLogicVecVal* dp, const svLogicVecVal* sp, int lsb, int
}
}
// Clean result
dp[VL_WORDS_I(width)-1].aval &= VL_MASK_I(width);
dp[VL_WORDS_I(width)-1].bval &= VL_MASK_I(width);
dp[VL_WORDS_I(width) - 1].aval &= VL_MASK_I(width);
dp[VL_WORDS_I(width) - 1].bval &= VL_MASK_I(width);
}
void svPutPartselBit(svBitVecVal* dp, const svBitVecVal s, int lbit, int width) {
// See also _VL_INSERT_WI
int hbit = lbit+width-1;
int hbit = lbit + width - 1;
int hoffset = VL_BITBIT_I(hbit);
int loffset = VL_BITBIT_I(lbit);
if (hoffset==VL_SIZEBITS_I && loffset==0) {
if (hoffset == VL_SIZEBITS_I && loffset == 0) {
// Fast and common case, word based insertion
dp[VL_BITWORD_I(lbit)] = s;
}
else {
} else {
int hword = VL_BITWORD_I(hbit);
int lword = VL_BITWORD_I(lbit);
if (hword==lword) { // know < 32 bits because above checks it
IData insmask = (VL_MASK_I(hoffset-loffset+1))<<loffset;
dp[lword] = (dp[lword] & ~insmask) | ((s<<loffset) & insmask);
if (hword == lword) { // know < 32 bits because above checks it
IData insmask = (VL_MASK_I(hoffset - loffset + 1)) << loffset;
dp[lword] = (dp[lword] & ~insmask) | ((s << loffset) & insmask);
} else {
IData hinsmask = (VL_MASK_I(hoffset-0+1))<<0;
IData linsmask = (VL_MASK_I(31-loffset+1))<<loffset;
int nbitsonright = 32-loffset; // bits that end up in lword
dp[lword] = (dp[lword] & ~linsmask) | ((s<<loffset) & linsmask);
dp[hword] = (dp[hword] & ~hinsmask) | ((s>>nbitsonright) & hinsmask);
IData hinsmask = (VL_MASK_I(hoffset - 0 + 1)) << 0;
IData linsmask = (VL_MASK_I(31 - loffset + 1)) << loffset;
int nbitsonright = 32 - loffset; // bits that end up in lword
dp[lword] = (dp[lword] & ~linsmask) | ((s << loffset) & linsmask);
dp[hword] = (dp[hword] & ~hinsmask) | ((s >> nbitsonright) & hinsmask);
}
}
}
// cppcheck-suppress passedByValue
void svPutPartselLogic(svLogicVecVal* dp, const svLogicVecVal s, int lbit, int width) {
int hbit = lbit+width-1;
int hbit = lbit + width - 1;
int hoffset = VL_BITBIT_I(hbit);
int loffset = VL_BITBIT_I(lbit);
if (hoffset==VL_SIZEBITS_I && loffset==0) {
if (hoffset == VL_SIZEBITS_I && loffset == 0) {
// Fast and common case, word based insertion
dp[VL_BITWORD_I(lbit)].aval = s.aval;
dp[VL_BITWORD_I(lbit)].bval = s.bval;
}
else {
} else {
int hword = VL_BITWORD_I(hbit);
int lword = VL_BITWORD_I(lbit);
if (hword==lword) { // know < 32 bits because above checks it
IData insmask = (VL_MASK_I(hoffset-loffset+1))<<loffset;
dp[lword].aval = (dp[lword].aval & ~insmask) | ((s.aval<<loffset) & insmask);
dp[lword].bval = (dp[lword].bval & ~insmask) | ((s.bval<<loffset) & insmask);
if (hword == lword) { // know < 32 bits because above checks it
IData insmask = (VL_MASK_I(hoffset - loffset + 1)) << loffset;
dp[lword].aval = (dp[lword].aval & ~insmask) | ((s.aval << loffset) & insmask);
dp[lword].bval = (dp[lword].bval & ~insmask) | ((s.bval << loffset) & insmask);
} else {
IData hinsmask = (VL_MASK_I(hoffset-0+1))<<0;
IData linsmask = (VL_MASK_I(31-loffset+1))<<loffset;
int nbitsonright = 32-loffset; // bits that end up in lword
dp[lword].aval = (dp[lword].aval & ~linsmask) | ((s.aval<<loffset) & linsmask);
dp[lword].bval = (dp[lword].bval & ~linsmask) | ((s.bval<<loffset) & linsmask);
dp[hword].aval = (dp[hword].aval & ~hinsmask) | ((s.aval>>nbitsonright) & hinsmask);
dp[hword].bval = (dp[hword].bval & ~hinsmask) | ((s.bval>>nbitsonright) & hinsmask);
IData hinsmask = (VL_MASK_I(hoffset - 0 + 1)) << 0;
IData linsmask = (VL_MASK_I(31 - loffset + 1)) << loffset;
int nbitsonright = 32 - loffset; // bits that end up in lword
dp[lword].aval = (dp[lword].aval & ~linsmask) | ((s.aval << loffset) & linsmask);
dp[lword].bval = (dp[lword].bval & ~linsmask) | ((s.bval << loffset) & linsmask);
dp[hword].aval = (dp[hword].aval & ~hinsmask) | ((s.aval >> nbitsonright) & hinsmask);
dp[hword].bval = (dp[hword].bval & ~hinsmask) | ((s.bval >> nbitsonright) & hinsmask);
}
}
}
@@ -191,7 +176,7 @@ void svPutPartselLogic(svLogicVecVal* dp, const svLogicVecVal s, int lbit, int w
static inline const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHandle h) {
if (VL_UNLIKELY(!h)) {
VL_FATAL_MT(__FILE__, __LINE__, "",
"%%Error: DPI svOpenArrayHandle function called with NULL handle");
"%%Error: DPI svOpenArrayHandle function called with nullptr handle");
}
const VerilatedDpiOpenVar* varp = reinterpret_cast<const VerilatedDpiOpenVar*>(h);
if (VL_UNLIKELY(!varp->magicOk())) {
@@ -204,31 +189,18 @@ static inline const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHa
//======================================================================
// Open array querying functions
int svLeft(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->left(d);
}
int svRight(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->right(d);
}
int svLow(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->low(d);
}
int svHigh(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->high(d);
}
int svIncrement(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->increment(d);
}
int svSize(const svOpenArrayHandle h, int d) {
return _vl_openhandle_varp(h)->elements(d);
}
int svDimensions(const svOpenArrayHandle h) {
return _vl_openhandle_varp(h)->udims();
}
/// Return pointer to open array data, or NULL if not in IEEE standard C layout
int svLeft(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->left(d); }
int svRight(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->right(d); }
int svLow(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->low(d); }
int svHigh(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->high(d); }
int svIncrement(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->increment(d); }
int svSize(const svOpenArrayHandle h, int d) { return _vl_openhandle_varp(h)->elements(d); }
int svDimensions(const svOpenArrayHandle h) { return _vl_openhandle_varp(h)->udims(); }
/// Return pointer to open array data, or nullptr if not in IEEE standard C layout
void* svGetArrayPtr(const svOpenArrayHandle h) {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(h);
if (VL_UNLIKELY(!varp->isDpiStdLayout())) return NULL;
if (VL_UNLIKELY(!varp->isDpiStdLayout())) return nullptr;
return varp->datap();
}
/// Return size of open array, or 0 if not in IEEE standard C layout
@@ -242,136 +214,145 @@ int svSizeOfArray(const svOpenArrayHandle h) {
//======================================================================
// Open array access internals
static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp,
int nargs, int indx1, int indx2, int indx3) {
static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp, int nargs, int indx1,
int indx2, int indx3) {
void* datap = varp->datap();
if (VL_UNLIKELY(nargs != varp->udims())) {
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function called on"
" %d dimensional array using %d dimensional function.\n",
varp->udims(), nargs);
return NULL;
return nullptr;
}
if (nargs>=1) {
if (nargs >= 1) {
datap = varp->datapAdjustIndex(datap, 1, indx1);
if (VL_UNLIKELY(!datap)) {
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 1 out of bounds; %d outside [%d:%d].\n",
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 1 "
"out of bounds; %d outside [%d:%d].\n",
indx1, varp->left(1), varp->right(1));
return NULL;
return nullptr;
}
}
if (nargs>=2) {
if (nargs >= 2) {
datap = varp->datapAdjustIndex(datap, 2, indx2);
if (VL_UNLIKELY(!datap)) {
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 2 out of bounds; %d outside [%d:%d].\n",
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 2 "
"out of bounds; %d outside [%d:%d].\n",
indx2, varp->left(2), varp->right(2));
return NULL;
return nullptr;
}
}
if (nargs>=3) {
if (nargs >= 3) {
datap = varp->datapAdjustIndex(datap, 3, indx3);
if (VL_UNLIKELY(!datap)) {
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 3 out of bounds; %d outside [%d:%d].\n",
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 3 "
"out of bounds; %d outside [%d:%d].\n",
indx1, varp->left(3), varp->right(3));
return NULL;
return nullptr;
}
}
return datap;
}
static int _vl_sv_adjusted_bit(const VerilatedDpiOpenVar* varp, int indx) {
if (VL_UNLIKELY(indx < varp->low(0) || indx > varp->high(0))) {
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function packed index out of bounds; %d outside [%d:%d].\n",
indx, varp->left(0), varp->right(0));
return 0;
}
return indx - varp->low(0);
}
/// Return pointer to simulator open array element, or NULL if outside range
static void* _vl_svGetArrElemPtr(const svOpenArrayHandle h,
int nargs, int indx1, int indx2, int indx3) VL_MT_SAFE {
/// Return pointer to simulator open array element, or nullptr if outside range
static void* _vl_svGetArrElemPtr(const svOpenArrayHandle h, int nargs, int indx1, int indx2,
int indx3) VL_MT_SAFE {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(h);
if (VL_UNLIKELY(!varp->isDpiStdLayout())) return NULL;
if (VL_UNLIKELY(!varp->isDpiStdLayout())) return nullptr;
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
return datap;
}
/// Copy to user bit array from simulator open array
static void _vl_svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s,
int nargs, int indx1, int indx2, int indx3) VL_MT_SAFE {
static void _vl_svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s, int nargs,
int indx1, int indx2, int indx3) VL_MT_SAFE {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(s);
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return;
switch (varp->vltype()) {
case VLVT_UINT8: d[0] = *(reinterpret_cast<CData*>(datap)); return;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8: d[0] = *(reinterpret_cast<CData*>(datap)); return;
case VLVT_UINT16: d[0] = *(reinterpret_cast<SData*>(datap)); return;
case VLVT_UINT32: d[0] = *(reinterpret_cast<IData*>(datap)); return;
case VLVT_UINT64: {
WData lwp[2]; VL_SET_WQ(lwp, *(reinterpret_cast<QData*>(datap)));
d[0] = lwp[0]; d[1] = lwp[1];
WData lwp[2];
VL_SET_WQ(lwp, *(reinterpret_cast<QData*>(datap)));
d[0] = lwp[0];
d[1] = lwp[1];
break;
}
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
for (int i=0; i<VL_WORDS_I(varp->packed().elements()); ++i) d[i] = wdatap[i];
for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) d[i] = wdatap[i];
return;
}
default:
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return;
return; // LCOV_EXCL_STOP
}
}
/// Copy to user logic array from simulator open array
static void _vl_svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s,
int nargs, int indx1, int indx2, int indx3) VL_MT_SAFE {
static void _vl_svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s, int nargs,
int indx1, int indx2, int indx3) VL_MT_SAFE {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(s);
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return;
switch (varp->vltype()) {
case VLVT_UINT8: d[0].aval = *(reinterpret_cast<CData*>(datap)); d[0].bval=0; return;
case VLVT_UINT16: d[0].aval = *(reinterpret_cast<SData*>(datap)); d[0].bval=0; return;
case VLVT_UINT32: d[0].aval = *(reinterpret_cast<IData*>(datap)); d[0].bval=0; return;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8:
d[0].aval = *(reinterpret_cast<CData*>(datap));
d[0].bval = 0;
return;
case VLVT_UINT16:
d[0].aval = *(reinterpret_cast<SData*>(datap));
d[0].bval = 0;
return;
case VLVT_UINT32:
d[0].aval = *(reinterpret_cast<IData*>(datap));
d[0].bval = 0;
return;
case VLVT_UINT64: {
WData lwp[2]; VL_SET_WQ(lwp, *(reinterpret_cast<QData*>(datap)));
d[0].aval = lwp[0]; d[0].bval=0;
d[1].aval = lwp[1]; d[0].bval=0;
WData lwp[2];
VL_SET_WQ(lwp, *(reinterpret_cast<QData*>(datap)));
d[0].aval = lwp[0];
d[0].bval = 0;
d[1].aval = lwp[1];
d[1].bval = 0;
break;
}
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
for (int i=0; i<VL_WORDS_I(varp->packed().elements()); ++i) {
d[i].aval = wdatap[i]; d[i].bval = 0;
for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) {
d[i].aval = wdatap[i];
d[i].bval = 0;
}
return;
}
default:
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return;
return; // LCOV_EXCL_STOP
}
}
/// Copy to simulator open array from from user bit array
static void _vl_svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s,
int nargs, int indx1, int indx2, int indx3) VL_MT_SAFE {
static void _vl_svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s, int nargs,
int indx1, int indx2, int indx3) VL_MT_SAFE {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(d);
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return;
switch (varp->vltype()) {
case VLVT_UINT8: *(reinterpret_cast<CData*>(datap)) = s[0]; return;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8: *(reinterpret_cast<CData*>(datap)) = s[0]; return;
case VLVT_UINT16: *(reinterpret_cast<SData*>(datap)) = s[0]; return;
case VLVT_UINT32: *(reinterpret_cast<IData*>(datap)) = s[0]; return;
case VLVT_UINT64: *(reinterpret_cast<QData*>(datap)) = _VL_SET_QII(s[1], s[0]); break;
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
for (int i=0; i<VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i];
for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i];
return;
}
default:
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return;
return; // LCOV_EXCL_STOP
}
}
/// Copy to simulator open array from from user logic array
@@ -380,82 +361,54 @@ static void _vl_svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogic
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(d);
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return;
switch (varp->vltype()) {
case VLVT_UINT8: *(reinterpret_cast<CData*>(datap)) = s[0].aval; return;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8: *(reinterpret_cast<CData*>(datap)) = s[0].aval; return;
case VLVT_UINT16: *(reinterpret_cast<SData*>(datap)) = s[0].aval; return;
case VLVT_UINT32: *(reinterpret_cast<IData*>(datap)) = s[0].aval; return;
case VLVT_UINT64: *(reinterpret_cast<QData*>(datap)) = _VL_SET_QII(s[1].aval, s[0].aval); break;
case VLVT_UINT64:
*(reinterpret_cast<QData*>(datap)) = _VL_SET_QII(s[1].aval, s[0].aval);
break;
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
for (int i=0; i<VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i].aval;
for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i].aval;
return;
}
default:
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype());
return;
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return; // LCOV_EXCL_STOP
}
}
/// Return bit from simulator open array
static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s,
int nargs, int indx1, int indx2, int indx3, int indx4) VL_MT_SAFE {
static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s, int nargs, int indx1, int indx2,
int indx3, int indx4) VL_MT_SAFE {
// One extra index supported, as need bit number
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(s);
void* datap;
int lsb;
if (varp->packed().elements()) {
datap = _vl_sv_adjusted_datap(varp, nargs-1, indx1, indx2, indx3);
lsb = _vl_sv_adjusted_bit(varp, ((nargs==1) ? indx1
: (nargs==2) ? indx2
: (nargs==3) ? indx3
: indx4));
} else {
datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
lsb = 0;
}
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return 0;
switch (varp->vltype()) {
case VLVT_UINT8: return (*(reinterpret_cast<CData*>(datap)) >> lsb) & 1;
case VLVT_UINT16: return (*(reinterpret_cast<SData*>(datap)) >> lsb) & 1;
case VLVT_UINT32: return (*(reinterpret_cast<IData*>(datap)) >> lsb) & 1;
case VLVT_UINT64: return (*(reinterpret_cast<QData*>(datap)) >> static_cast<QData>(lsb)) & VL_ULL(1);
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
return VL_BITRSHIFT_W(wdatap, lsb) & 1;
}
default:
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype());
return 0;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8: return (*(reinterpret_cast<CData*>(datap))) & 1;
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return 0; // LCOV_EXCL_STOP
}
}
/// Update simulator open array from bit
static void _vl_svPutBitArrElem(const svOpenArrayHandle d, svBit value,
int nargs, int indx1, int indx2, int indx3, int indx4) VL_MT_SAFE {
static void _vl_svPutBitArrElem(const svOpenArrayHandle d, svBit value, int nargs, int indx1,
int indx2, int indx3, int indx4) VL_MT_SAFE {
// One extra index supported, as need bit number
value &= 1; // Make sure clean
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(d);
void* datap;
int lsb;
if (varp->packed().elements()) {
datap = _vl_sv_adjusted_datap(varp, nargs-1, indx1, indx2, indx3);
lsb = _vl_sv_adjusted_bit(varp, ((nargs==1) ? indx1
: (nargs==2) ? indx2
: (nargs==3) ? indx3
: indx4));
} else {
datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
lsb = 0;
}
void* datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3);
if (VL_UNLIKELY(!datap)) return;
switch (varp->vltype()) {
case VLVT_UINT8: VL_ASSIGNBIT_II(-1, lsb, *(reinterpret_cast<CData*>(datap)), value); return;
case VLVT_UINT16: VL_ASSIGNBIT_II(-1, lsb, *(reinterpret_cast<SData*>(datap)), value); return;
case VLVT_UINT32: VL_ASSIGNBIT_II(-1, lsb, *(reinterpret_cast<IData*>(datap)), value); return;
case VLVT_UINT64: VL_ASSIGNBIT_QI(-1, lsb, *(reinterpret_cast<QData*>(datap)), value); return;
case VLVT_WDATA: VL_ASSIGNBIT_WI(-1, lsb, (reinterpret_cast<WDataOutP>(datap)), value); return;
default:
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype());
return;
switch (varp->vltype()) { // LCOV_EXCL_BR_LINE
case VLVT_UINT8: *(reinterpret_cast<CData*>(datap)) = value; return;
default: // LCOV_EXCL_START // Errored earlier
_VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n",
varp->vltype());
return; // LCOV_EXCL_STOP
}
}
@@ -470,10 +423,17 @@ void* svGetArrElemPtr(const svOpenArrayHandle h, int indx1, ...) {
// va_arg is a macro, so need temporaries as used below
switch (varp->udims()) {
case 1: datap = _vl_svGetArrElemPtr(h, 1, indx1, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
datap = _vl_svGetArrElemPtr(h, 2, indx1, indx2, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
datap = _vl_svGetArrElemPtr(h, 3, indx1, indx2, indx3); break; }
case 2: {
int indx2 = va_arg(ap, int);
datap = _vl_svGetArrElemPtr(h, 2, indx1, indx2, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
datap = _vl_svGetArrElemPtr(h, 3, indx1, indx2, indx3);
break;
}
default: datap = _vl_svGetArrElemPtr(h, -1, 0, 0, 0); break; // Will error
}
va_end(ap);
@@ -489,116 +449,134 @@ void* svGetArrElemPtr3(const svOpenArrayHandle h, int indx1, int indx2, int indx
return _vl_svGetArrElemPtr(h, 3, indx1, indx2, indx3);
}
void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s,
int indx1, ...) {
void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1, ...) {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(d);
va_list ap;
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svPutBitArrElemVecVal(d, s, 1, indx1, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svPutBitArrElemVecVal(d, s, 2, indx1, indx2, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svPutBitArrElemVecVal(d, s, 3, indx1, indx2, indx3); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svPutBitArrElemVecVal(d, s, 2, indx1, indx2, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svPutBitArrElemVecVal(d, s, 3, indx1, indx2, indx3);
break;
}
default: _vl_svPutBitArrElemVecVal(d, s, -1, 0, 0, 0); break; // Will error
}
va_end(ap);
}
void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
int indx1) {
void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1) {
_vl_svPutBitArrElemVecVal(d, s, 1, indx1, 0, 0);
}
void svPutBitArrElem2VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
int indx1, int indx2) {
void svPutBitArrElem2VecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1,
int indx2) {
_vl_svPutBitArrElemVecVal(d, s, 2, indx1, indx2, 0);
}
void svPutBitArrElem3VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
int indx1, int indx2, int indx3) {
void svPutBitArrElem3VecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1, int indx2,
int indx3) {
_vl_svPutBitArrElemVecVal(d, s, 3, indx1, indx2, indx3);
}
void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
int indx1, ...) {
void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1, ...) {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(d);
va_list ap;
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svPutLogicArrElemVecVal(d, s, 1, indx1, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svPutLogicArrElemVecVal(d, s, 2, indx1, indx2, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svPutLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svPutLogicArrElemVecVal(d, s, 2, indx1, indx2, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svPutLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3);
break;
}
default: _vl_svPutLogicArrElemVecVal(d, s, -1, 0, 0, 0); break; // Will error
}
va_end(ap);
}
void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
int indx1) {
void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1) {
_vl_svPutLogicArrElemVecVal(d, s, 1, indx1, 0, 0);
}
void svPutLogicArrElem2VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
int indx1, int indx2) {
void svPutLogicArrElem2VecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1,
int indx2) {
_vl_svPutLogicArrElemVecVal(d, s, 2, indx1, indx2, 0);
}
void svPutLogicArrElem3VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
int indx1, int indx2, int indx3) {
void svPutLogicArrElem3VecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1,
int indx2, int indx3) {
_vl_svPutLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3);
}
//======================================================================
// From simulator storage into user space
void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s,
int indx1, ...) {
void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1, ...) {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(s);
va_list ap;
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svGetBitArrElemVecVal(d, s, 1, indx1, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svGetBitArrElemVecVal(d, s, 2, indx1, indx2, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svGetBitArrElemVecVal(d, s, 3, indx1, indx2, indx3); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svGetBitArrElemVecVal(d, s, 2, indx1, indx2, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svGetBitArrElemVecVal(d, s, 3, indx1, indx2, indx3);
break;
}
default: _vl_svGetBitArrElemVecVal(d, s, -1, 0, 0, 0); break; // Will error
}
va_end(ap);
}
void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s,
int indx1) {
void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1) {
_vl_svGetBitArrElemVecVal(d, s, 1, indx1, 0, 0);
}
void svGetBitArrElem2VecVal(svBitVecVal* d, const svOpenArrayHandle s,
int indx1, int indx2) {
void svGetBitArrElem2VecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1, int indx2) {
_vl_svGetBitArrElemVecVal(d, s, 2, indx1, indx2, 0);
}
void svGetBitArrElem3VecVal(svBitVecVal* d, const svOpenArrayHandle s,
int indx1, int indx2, int indx3) {
void svGetBitArrElem3VecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1, int indx2,
int indx3) {
_vl_svGetBitArrElemVecVal(d, s, 3, indx1, indx2, indx3);
}
void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s,
int indx1, ...) {
void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1, ...) {
const VerilatedDpiOpenVar* varp = _vl_openhandle_varp(s);
va_list ap;
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svGetLogicArrElemVecVal(d, s, 1, indx1, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svGetLogicArrElemVecVal(d, s, 2, indx1, indx2, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svGetLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svGetLogicArrElemVecVal(d, s, 2, indx1, indx2, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svGetLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3);
break;
}
default: _vl_svGetLogicArrElemVecVal(d, s, -1, 0, 0, 0); break; // Will error
}
va_end(ap);
}
void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
int indx1) {
void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1) {
_vl_svGetLogicArrElemVecVal(d, s, 1, indx1, 0, 0);
}
void svGetLogicArrElem2VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
int indx1, int indx2) {
void svGetLogicArrElem2VecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1, int indx2) {
_vl_svGetLogicArrElemVecVal(d, s, 2, indx1, indx2, 0);
}
void svGetLogicArrElem3VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
int indx1, int indx2, int indx3) {
void svGetLogicArrElem3VecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1, int indx2,
int indx3) {
_vl_svGetLogicArrElemVecVal(d, s, 3, indx1, indx2, indx3);
}
@@ -609,12 +587,17 @@ svBit svGetBitArrElem(const svOpenArrayHandle s, int indx1, ...) {
va_start(ap, indx1);
switch (varp->udims()) {
case 1: out = _vl_svGetBitArrElem(s, 1, indx1, 0, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 2, indx1, indx2, 0, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 3, indx1, indx2, indx3, 0); break; }
case 4: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int); int indx4=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 4, indx1, indx2, indx3, indx4); break; }
case 2: {
int indx2 = va_arg(ap, int);
out = _vl_svGetBitArrElem(s, 2, indx1, indx2, 0, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
out = _vl_svGetBitArrElem(s, 3, indx1, indx2, indx3, 0);
break;
}
default: out = _vl_svGetBitArrElem(s, -1, 0, 0, 0, 0); break; // Will error
}
va_end(ap);
@@ -637,12 +620,17 @@ svLogic svGetLogicArrElem(const svOpenArrayHandle s, int indx1, ...) {
va_start(ap, indx1);
switch (varp->udims()) {
case 1: out = _vl_svGetBitArrElem(s, 1, indx1, 0, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 2, indx1, indx2, 0, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 3, indx1, indx2, indx3, 0); break; }
case 4: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int); int indx4=va_arg(ap,int);
out = _vl_svGetBitArrElem(s, 4, indx1, indx2, indx3, indx4); break; }
case 2: {
int indx2 = va_arg(ap, int);
out = _vl_svGetBitArrElem(s, 2, indx1, indx2, 0, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
out = _vl_svGetBitArrElem(s, 3, indx1, indx2, indx3, 0);
break;
}
default: out = _vl_svGetBitArrElem(s, -1, 0, 0, 0, 0); break; // Will error
}
va_end(ap);
@@ -667,12 +655,17 @@ void svPutBitArrElem(const svOpenArrayHandle d, svBit value, int indx1, ...) {
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svPutBitArrElem(d, value, 1, indx1, 0, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 2, indx1, indx2, 0, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 3, indx1, indx2, indx3, 0); break; }
case 4: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int); int indx4=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 4, indx1, indx2, indx3, indx4); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svPutBitArrElem(d, value, 2, indx1, indx2, 0, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svPutBitArrElem(d, value, 3, indx1, indx2, indx3, 0);
break;
}
default: _vl_svPutBitArrElem(d, value, -1, 0, 0, 0, 0); break; // Will error
}
va_end(ap);
@@ -693,12 +686,17 @@ void svPutLogicArrElem(const svOpenArrayHandle d, svLogic value, int indx1, ...)
va_start(ap, indx1);
switch (varp->udims()) {
case 1: _vl_svPutBitArrElem(d, value, 1, indx1, 0, 0, 0); break;
case 2: { int indx2=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 2, indx1, indx2, 0, 0); break; }
case 3: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 3, indx1, indx2, indx3, 0); break; }
case 4: { int indx2=va_arg(ap,int); int indx3=va_arg(ap,int); int indx4=va_arg(ap,int);
_vl_svPutBitArrElem(d, value, 4, indx1, indx2, indx3, indx4); break; }
case 2: {
int indx2 = va_arg(ap, int);
_vl_svPutBitArrElem(d, value, 2, indx1, indx2, 0, 0);
break;
}
case 3: {
int indx2 = va_arg(ap, int);
int indx3 = va_arg(ap, int);
_vl_svPutBitArrElem(d, value, 3, indx1, indx2, indx3, 0);
break;
}
default: _vl_svPutBitArrElem(d, value, -1, 0, 0, 0, 0); break; // Will error
}
va_end(ap);
@@ -707,13 +705,12 @@ void svPutLogicArrElem1(const svOpenArrayHandle d, svLogic value, int indx1) {
// Verilator doesn't support X/Z so can just call Bit version
svPutBitArrElem1(d, value, indx1);
}
void svPutLogicArrElem2(const svOpenArrayHandle d, svLogic value,
int indx1, int indx2) {
void svPutLogicArrElem2(const svOpenArrayHandle d, svLogic value, int indx1, int indx2) {
// Verilator doesn't support X/Z so can just call Bit version
svPutBitArrElem2(d, value, indx1, indx2);
}
void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value,
int indx1, int indx2, int indx3) {
void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value, int indx1, int indx2,
int indx3) {
// Verilator doesn't support X/Z so can just call Bit version
svPutBitArrElem3(d, value, indx1, indx2, indx3);
}
@@ -722,7 +719,10 @@ void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value,
// Functions for working with DPI context
svScope svGetScope() {
if (VL_UNLIKELY(!Verilated::dpiInContext())) { _VL_SVDPI_CONTEXT_WARN(); return NULL; }
if (VL_UNLIKELY(!Verilated::dpiInContext())) {
_VL_SVDPI_CONTEXT_WARN();
return nullptr;
}
// NOLINTNEXTLINE(google-readability-casting)
return (svScope)(Verilated::dpiScope());
}
@@ -746,16 +746,19 @@ svScope svGetScopeFromName(const char* scopeName) {
}
int svPutUserData(const svScope scope, void* userKey, void* userData) {
VerilatedImp::userInsert(scope,userKey,userData);
VerilatedImp::userInsert(scope, userKey, userData);
return 0;
}
void* svGetUserData(const svScope scope, void* userKey) {
return VerilatedImp::userFind(scope,userKey);
return VerilatedImp::userFind(scope, userKey);
}
int svGetCallerInfo(const char** fileNamepp, int *lineNumberp) {
if (VL_UNLIKELY(!Verilated::dpiInContext())) { _VL_SVDPI_CONTEXT_WARN(); return false; }
int svGetCallerInfo(const char** fileNamepp, int* lineNumberp) {
if (VL_UNLIKELY(!Verilated::dpiInContext())) {
_VL_SVDPI_CONTEXT_WARN();
return false;
}
if (VL_LIKELY(fileNamepp)) *fileNamepp = Verilated::dpiFilenamep(); // thread local
if (VL_LIKELY(lineNumberp)) *lineNumberp = Verilated::dpiLineno(); // thread local
return true;
+34 -20
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -32,45 +32,59 @@
//===================================================================
// SETTING OPERATORS
/// Return WData from svBitVecVal
/// Convert svBitVecVal to Verilator internal data
static inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lwp) VL_MT_SAFE {
int words = VL_WORDS_I(obits);
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i];
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
}
/// Return svBitVecVal from WData
static inline QData VL_SET_Q_SVBV(const svBitVecVal* lwp) VL_MT_SAFE {
return _VL_SET_QII(lwp[1], lwp[0]);
}
static inline IData VL_SET_I_SVBV(const svBitVecVal* lwp) VL_MT_SAFE { return lwp[0]; }
/// Convert Verilator internal data to svBitVecVal
static inline void VL_SET_SVBV_W(int obits, svBitVecVal* owp, WDataInP lwp) VL_MT_SAFE {
int words = VL_WORDS_I(obits);
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i];
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
}
static inline void VL_SET_SVBV_I(int, svBitVecVal* owp, IData ld) VL_MT_SAFE { owp[0] = ld; }
static inline void VL_SET_SVBV_Q(int, svBitVecVal* owp, QData ld) VL_MT_SAFE {
VL_SET_WQ(owp, ld);
}
/// Convert svLogicVecVal to/from WData
/// Convert svLogicVecVal to Verilator internal data
/// Note these functions ignore X/Z in svLogicVecVal
static inline void VL_SET_W_SVLV(int obits, WDataOutP owp, const svLogicVecVal* lwp) VL_MT_SAFE {
int words = VL_WORDS_I(obits);
for (int i=0; i<words-1; ++i) owp[i]=lwp[i].aval;
owp[words-1] = lwp[words-1].aval & VL_MASK_I(obits);
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i].aval;
owp[words - 1] = lwp[words - 1].aval & VL_MASK_I(obits);
}
static inline QData VL_SET_Q_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
return _VL_SET_QII(lwp[1].aval, lwp[0].aval);
}
static inline IData VL_SET_I_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
return lwp[0].aval;
}
static inline IData VL_SET_I_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE { return lwp[0].aval; }
/// Convert Verilator internal data to svLogicVecVal
/// Note these functions never create X/Z in svLogicVecVal
static inline void VL_SET_SVLV_W(int obits, svLogicVecVal* owp, WDataInP lwp) VL_MT_SAFE {
int words = VL_WORDS_I(obits);
for (int i=0; i<words; ++i) owp[i].bval=0;
for (int i=0; i<words-1; ++i) owp[i].aval=lwp[i];
owp[words-1].aval = lwp[words-1] & VL_MASK_I(obits);
for (int i = 0; i < words; ++i) owp[i].bval = 0;
for (int i = 0; i < words - 1; ++i) owp[i].aval = lwp[i];
owp[words - 1].aval = lwp[words - 1] & VL_MASK_I(obits);
}
static inline void VL_SET_SVLV_I(int, svLogicVecVal* owp, IData ld) VL_MT_SAFE {
owp[0].aval=ld; owp[0].bval=0;
owp[0].aval = ld;
owp[0].bval = 0;
}
static inline void VL_SET_SVLV_Q(int, svLogicVecVal* owp, QData ld) VL_MT_SAFE {
WData lwp[2]; VL_SET_WQ(lwp,ld);
owp[0].aval=lwp[0]; owp[0].bval=0;
owp[1].aval=lwp[1]; owp[1].bval=0;
WData lwp[2];
VL_SET_WQ(lwp, ld);
owp[0].aval = lwp[0];
owp[0].bval = 0;
owp[1].aval = lwp[1];
owp[1].bval = 0;
}
//======================================================================
+139 -101
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -17,13 +17,14 @@
//=============================================================================
// SPDIFF_OFF
// clang-format off
#define __STDC_LIMIT_MACROS // UINT64_MAX
#include "verilatedos.h"
#include "verilated.h"
#include "verilated_fst_c.h"
// GTKWave configuration
#ifdef VL_TRACE_THREADED
#ifdef VL_TRACE_FST_WRITER_THREAD
# define HAVE_LIBPTHREAD
# define FST_WRITER_PARALLEL
#endif
@@ -35,116 +36,111 @@
#include "gtkwave/lz4.c"
#include <algorithm>
#include <cerrno>
#include <ctime>
#include <fcntl.h>
#include <iterator>
#include <sstream>
#include <sys/stat.h>
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# include <io.h>
#else
# include <stdint.h>
# include <unistd.h>
#endif
//=============================================================================
// clang-format on
class VerilatedFstCallInfo {
protected:
friend class VerilatedFst;
VerilatedFstCallback_t m_initcb; ///< Initialization Callback function
VerilatedFstCallback_t m_fullcb; ///< Full Dumping Callback function
VerilatedFstCallback_t m_changecb; ///< Incremental Dumping Callback function
void* m_userthis; ///< Fake "this" for caller
vluint32_t m_code; ///< Starting code number
// CONSTRUCTORS
VerilatedFstCallInfo(VerilatedFstCallback_t icb, VerilatedFstCallback_t fcb,
VerilatedFstCallback_t changecb, void* ut)
: m_initcb(icb)
, m_fullcb(fcb)
, m_changecb(changecb)
, m_userthis(ut)
, m_code(1) {}
~VerilatedFstCallInfo() {}
};
//=============================================================================
// Specialization of the generics for this trace format
#define VL_DERIVED_T VerilatedFst
#include "verilated_trace_imp.cpp"
#undef VL_DERIVED_T
//=============================================================================
// VerilatedFst
VerilatedFst::VerilatedFst(void* fst)
: m_fst(fst)
, m_fullDump(true)
, m_nextCode(1)
, m_scopeEscape('.') {
m_valueStrBuffer.reserve(64 + 1); // Need enough room for quad
: m_fst{fst} {}
VerilatedFst::~VerilatedFst() {
if (m_fst) fstWriterClose(m_fst);
if (m_symbolp) VL_DO_CLEAR(delete[] m_symbolp, m_symbolp = nullptr);
if (m_strbuf) VL_DO_CLEAR(delete[] m_strbuf, m_strbuf = nullptr);
}
void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
m_assertOne.check();
m_fst = fstWriterCreate(filename, 1);
fstWriterSetPackType(m_fst, FST_WR_PT_LZ4);
#ifdef VL_TRACE_THREADED
fstWriterSetTimescaleFromString(m_fst, timeResStr().c_str()); // lintok-begin-on-ref
#ifdef VL_TRACE_FST_WRITER_THREAD
fstWriterSetParallelMode(m_fst, 1);
#endif
m_curScope.clear();
m_nextCode = 1;
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[ent];
cip->m_code = m_nextCode;
// Initialize; callbacks will call decl* which update m_nextCode
(cip->m_initcb)(this, cip->m_userthis, cip->m_code);
}
m_curScope.clear();
VerilatedTrace<VerilatedFst>::traceInit();
// Clear the scope stack
std::list<std::string>::iterator it = m_curScope.begin();
auto it = m_curScope.begin();
while (it != m_curScope.end()) {
fstWriterSetUpscope(m_fst);
it = m_curScope.erase(it);
}
// convert m_code2symbol into an array for fast lookup
if (!m_symbolp) {
m_symbolp = new fstHandle[nextCode()];
for (const auto& i : m_code2symbol) m_symbolp[i.first] = i.second;
}
m_code2symbol.clear();
// Allocate string buffer for arrays
if (!m_strbuf) { m_strbuf = new char[maxBits() + 32]; }
}
void VerilatedFst::module(const std::string& name) {
m_module = name;
void VerilatedFst::close() {
m_assertOne.check();
VerilatedTrace<VerilatedFst>::close();
fstWriterClose(m_fst);
m_fst = nullptr;
}
void VerilatedFst::flush() {
VerilatedTrace<VerilatedFst>::flush();
fstWriterFlushContext(m_fst);
}
void VerilatedFst::emitTimeChange(vluint64_t timeui) { fstWriterEmitTimeChange(m_fst, timeui); }
//=============================================================================
// Decl
void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elements,
unsigned int minValbits,
const char** itemNamesp, const char** itemValuesp) {
fstEnumHandle enumNum = fstWriterCreateEnumTable(m_fst, name, elements,
minValbits, itemNamesp, itemValuesp);
unsigned int minValbits, const char** itemNamesp,
const char** itemValuesp) {
fstEnumHandle enumNum
= fstWriterCreateEnumTable(m_fst, name, elements, minValbits, itemNamesp, itemValuesp);
m_local2fstdtype[dtypenum] = enumNum;
}
void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, vluint32_t len,
vluint32_t bits) {
void VerilatedFst::declare(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb) {
const int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
// 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);
VerilatedTrace<VerilatedFst>::declCode(code, bits, false);
std::pair<Code2SymbolType::iterator, bool> p
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
std::istringstream nameiss(name);
std::istream_iterator<std::string> beg(nameiss), end;
std::istream_iterator<std::string> beg(nameiss);
std::istream_iterator<std::string> end;
std::list<std::string> tokens(beg, end); // Split name
std::string symbol_name(tokens.back());
tokens.pop_back(); // Remove symbol name from hierarchy
tokens.insert(tokens.begin(), m_module); // Add current module to the hierarchy
tokens.insert(tokens.begin(), moduleName()); // Add current module to the hierarchy
// Find point where current and new scope diverge
std::list<std::string>::iterator cur_it = m_curScope.begin();
std::list<std::string>::iterator new_it = tokens.begin();
auto cur_it = m_curScope.begin();
auto new_it = tokens.begin();
while (cur_it != m_curScope.end() && new_it != tokens.end()) {
if (*cur_it != *new_it)
break;
if (*cur_it != *new_it) break;
++cur_it;
++new_it;
}
@@ -157,7 +153,7 @@ void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, f
// Follow the hierarchy of the new variable from the common scope point
while (new_it != tokens.end()) {
fstWriterSetScope(m_fst, FST_ST_VCD_SCOPE, new_it->c_str(), NULL);
fstWriterSetScope(m_fst, FST_ST_VCD_SCOPE, new_it->c_str(), nullptr);
m_curScope.push_back(*new_it);
new_it = tokens.erase(new_it);
}
@@ -171,49 +167,91 @@ void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, f
fstEnumHandle enumNum = m_local2fstdtype[dtypenum];
fstWriterEmitEnumTableRef(m_fst, enumNum);
}
if (p.second) { // New
p.first->second = fstWriterCreateVar(m_fst, vartype, vardir, len, name_str.c_str(), 0);
assert(p.first->second);
const auto it = vlstd::as_const(m_code2symbol).find(code);
if (it == m_code2symbol.end()) { // New
m_code2symbol[code]
= fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), 0);
} else { // Alias
fstWriterCreateVar(m_fst, vartype, vardir, len, name_str.c_str(), p.first->second);
fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), it->second);
}
}
//=============================================================================
// Callbacks
void VerilatedFst::addCallback(VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb,
VerilatedFstCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
m_assertOne.check();
if (VL_UNLIKELY(isOpen())) {
std::string msg = (std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
+ " called with already open file");
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
}
VerilatedFstCallInfo* cip = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis);
m_callbacks.push_back(cip);
void VerilatedFst::declBit(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum) {
declare(code, name, dtypenum, vardir, vartype, array, arraynum, 0, 0);
}
void VerilatedFst::declBus(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb) {
declare(code, name, dtypenum, vardir, vartype, array, arraynum, msb, lsb);
}
void VerilatedFst::declQuad(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb) {
declare(code, name, dtypenum, vardir, vartype, array, arraynum, msb, lsb);
}
void VerilatedFst::declArray(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb) {
declare(code, name, dtypenum, vardir, vartype, array, arraynum, msb, lsb);
}
void VerilatedFst::declDouble(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum) {
declare(code, name, dtypenum, vardir, vartype, array, arraynum, 63, 0);
}
//=============================================================================
// Dumping
// Note: emit* are only ever called from one place (full* in
// verilated_trace_imp.cpp, which is included in this file at the top),
// so always inline them.
void VerilatedFst::dump(vluint64_t timeui) {
if (!isOpen()) return;
if (VL_UNLIKELY(m_fullDump)) {
m_fullDump = false; // No more need for next dump to be full
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[ent];
(cip->m_fullcb)(this, cip->m_userthis, cip->m_code);
}
return;
}
fstWriterEmitTimeChange(m_fst, timeui);
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[ent];
(cip->m_changecb)(this, cip->m_userthis, cip->m_code);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitBit(vluint32_t code, CData newval) {
fstWriterEmitValueChange(m_fst, m_symbolp[code], newval ? "1" : "0");
}
//********************************************************************
// Local Variables:
// End:
VL_ATTR_ALWINLINE
void VerilatedFst::emitCData(vluint32_t code, CData newval, int bits) {
char buf[VL_BYTESIZE];
cvtCDataToStr(buf, newval << (VL_BYTESIZE - bits));
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitSData(vluint32_t code, SData newval, int bits) {
char buf[VL_SHORTSIZE];
cvtSDataToStr(buf, newval << (VL_SHORTSIZE - bits));
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitIData(vluint32_t code, IData newval, int bits) {
char buf[VL_IDATASIZE];
cvtIDataToStr(buf, newval << (VL_IDATASIZE - bits));
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitQData(vluint32_t code, QData newval, int bits) {
char buf[VL_QUADSIZE];
cvtQDataToStr(buf, newval << (VL_QUADSIZE - bits));
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitWData(vluint32_t code, const WData* newvalp, int bits) {
int words = VL_WORDS_I(bits);
char* wp = m_strbuf;
// Convert the most significant word
const int bitsInMSW = VL_BITBIT_E(bits) ? VL_BITBIT_E(bits) : VL_EDATASIZE;
cvtEDataToStr(wp, newvalp[--words] << (VL_EDATASIZE - bitsInMSW));
wp += bitsInMSW;
// Convert the remaining words
while (words > 0) {
cvtEDataToStr(wp, newvalp[--words]);
wp += VL_EDATASIZE;
}
fstWriterEmitValueChange(m_fst, m_symbolp[code], m_strbuf);
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitDouble(vluint32_t code, double newval) {
fstWriterEmitValueChange(m_fst, m_symbolp[code], &newval);
}
+81 -144
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -20,8 +20,8 @@
#ifndef _VERILATED_FST_C_H_
#define _VERILATED_FST_C_H_ 1
#include "verilatedos.h"
#include "verilated.h"
#include "verilated_trace.h"
#include "gtkwave/fstapi.h"
@@ -30,180 +30,117 @@
#include <string>
#include <vector>
class VerilatedFst;
class VerilatedFstCallInfo;
typedef void (*VerilatedFstCallback_t)(VerilatedFst* vcdp, void* userthis, vluint32_t code);
//=============================================================================
// VerilatedFst
/// Base class to create a Verilator FST dump
/// This is an internally used class - see VerilatedFstC for what to call from applications
class VerilatedFst {
class VerilatedFst final : public VerilatedTrace<VerilatedFst> {
private:
// Give the superclass access to private bits (to avoid virtual functions)
friend class VerilatedTrace<VerilatedFst>;
//=========================================================================
// FST specific internals
typedef std::map<vluint32_t, fstHandle> Code2SymbolType;
typedef std::map<int, fstEnumHandle> Local2FstDtype;
typedef std::vector<VerilatedFstCallInfo*> CallbackVec;
private:
void* m_fst;
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
bool m_fullDump;
vluint32_t m_nextCode; ///< Next code number to assign
char m_scopeEscape;
std::string m_module;
CallbackVec m_callbacks; ///< Routines to perform dumping
Code2SymbolType m_code2symbol;
Local2FstDtype m_local2fstdtype;
std::list<std::string> m_curScope;
fstHandle* m_symbolp = nullptr; ///< same as m_code2symbol, but as an array
char* m_strbuf = nullptr; ///< String buffer long enough to hold maxBits() chars
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedFst);
void declSymbol(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, vluint32_t len, vluint32_t bits);
// helpers
std::vector<char> m_valueStrBuffer;
void declare(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb);
protected:
//=========================================================================
// Implementation of VerilatedTrace interface
// Implementations of protected virtual methods for VerilatedTrace
virtual void emitTimeChange(vluint64_t timeui) override;
// Hooks called from VerilatedTrace
virtual bool preFullDump() override { return isOpen(); }
virtual bool preChangeDump() override { return isOpen(); }
// Implementations of duck-typed methods for VerilatedTrace. These are
// called from only one place (namely full*) so always inline them.
inline void emitBit(vluint32_t code, CData newval);
inline void emitCData(vluint32_t code, CData newval, int bits);
inline void emitSData(vluint32_t code, SData newval, int bits);
inline void emitIData(vluint32_t code, IData newval, int bits);
inline void emitQData(vluint32_t code, QData newval, int bits);
inline void emitWData(vluint32_t code, const WData* newvalp, int bits);
inline void emitDouble(vluint32_t code, double newval);
public:
explicit VerilatedFst(void* fst=NULL);
~VerilatedFst() { if (m_fst == NULL) { fstWriterClose(m_fst); } }
void changeThread() { m_assertOne.changeThread(); }
bool isOpen() const { return m_fst != NULL; }
//=========================================================================
// External interface to client code
explicit VerilatedFst(void* fst = nullptr);
~VerilatedFst();
/// Open the file; call isOpen() to see if errors
void open(const char* filename) VL_MT_UNSAFE;
void flush() VL_MT_UNSAFE { fstWriterFlushContext(m_fst); }
void close() VL_MT_UNSAFE {
m_assertOne.check();
fstWriterClose(m_fst);
m_fst = NULL;
}
void set_time_unit(const char* unitp) { fstWriterSetTimescaleFromString(m_fst, unitp); }
void set_time_unit(const std::string& unit) { set_time_unit(unit.c_str()); }
/// Close the file
void close() VL_MT_UNSAFE;
/// Flush any remaining data to this file
void flush() VL_MT_UNSAFE;
/// Is file open?
bool isOpen() const { return m_fst != nullptr; }
void set_time_resolution(const char* unitp) { if (unitp) {} }
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
//=========================================================================
// Internal interface to Verilator generated code
// double timescaleToDouble(const char* unitp);
// std::string doubleToTimescale(double value);
/// Change character that splits scopes. Note whitespace are ALWAYS escapes.
void scopeEscape(char flag) { m_scopeEscape = flag; }
/// Is this an escape?
bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; }
/// Inside dumping routines, called each cycle to make the dump
void dump(vluint64_t timeui);
/// Inside dumping routines, declare callbacks for tracings
void addCallback(VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb,
VerilatedFstCallback_t changecb,
void* userthis) VL_MT_UNSAFE_ONE;
/// Inside dumping routines, declare a module
void module(const std::string& name);
/// Inside dumping routines, declare a data type
void declDTypeEnum(int dtypenum, const char* name, vluint32_t elements,
unsigned int minValbits,
const char** itemNamesp, const char** itemValuesp);
unsigned int minValbits, const char** itemNamesp, const char** itemValuesp);
/// Inside dumping routines, declare a signal
void declBit(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 1);
}
void declBus(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
void declDouble(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 2, 64);
}
void declFloat(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 32);
}
void declQuad(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
void declArray(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
/// Inside dumping routines, dump one signal if it has changed
void chgBit(vluint32_t code, const vluint32_t newval) {
fstWriterEmitValueChange(m_fst, m_code2symbol[code], newval ? "1" : "0");
}
void chgBus(vluint32_t code, const vluint32_t newval, int bits) {
fstWriterEmitValueChange32(m_fst, m_code2symbol[code], bits, newval);
}
void chgDouble(vluint32_t code, const double newval) {
double val = newval;
fstWriterEmitValueChange(m_fst, m_code2symbol[code], &val);
}
void chgFloat(vluint32_t code, const float newval) {
double val = (double)newval;
fstWriterEmitValueChange(m_fst, m_code2symbol[code], &val);
}
void chgQuad(vluint32_t code, const vluint64_t newval, int bits) {
fstWriterEmitValueChange64(m_fst, m_code2symbol[code], bits, newval);
}
void chgArray(vluint32_t code, const vluint32_t* newval, int bits) {
fstWriterEmitValueChangeVec32(m_fst, m_code2symbol[code], bits, newval);
}
void fullBit(vluint32_t code, const vluint32_t newval) {
chgBit(code, newval); }
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
chgBus(code, newval, bits); }
void fullDouble(vluint32_t code, const double newval) {
chgDouble(code, newval); }
void fullFloat(vluint32_t code, const float newval) {
chgFloat(code, newval); }
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
chgQuad(code, newval, bits); }
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
chgArray(code, newval, bits); }
void declTriBit(vluint32_t code, const char* name, int arraynum);
void declTriBus(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
void declTriQuad(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
void declTriArray(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri);
void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits);
void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits);
void fullTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits);
void fullBitX(vluint32_t code);
void fullBusX(vluint32_t code, int bits);
void fullQuadX(vluint32_t code, int bits);
void fullArrayX(vluint32_t code, int bits);
void chgTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri);
void chgTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits);
void chgTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits);
void chgTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits);
void declBit(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum);
void declBus(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb);
void declQuad(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb);
void declArray(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, int msb, int lsb);
void declDouble(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum);
};
// Declare specialization here as it's used in VerilatedFstC just below
template <> void VerilatedTrace<VerilatedFst>::dump(vluint64_t timeui);
template <> void VerilatedTrace<VerilatedFst>::set_time_unit(const char* unitp);
template <> void VerilatedTrace<VerilatedFst>::set_time_unit(const std::string& unit);
template <> void VerilatedTrace<VerilatedFst>::set_time_resolution(const char* unitp);
template <> void VerilatedTrace<VerilatedFst>::set_time_resolution(const std::string& unit);
//=============================================================================
// VerilatedFstC
/// Create a FST dump file in C standalone (no SystemC) simulations.
/// Also derived for use in SystemC simulations.
/// Thread safety: Unless otherwise indicated, every function is VL_MT_UNSAFE_ONE
class VerilatedFstC {
class VerilatedFstC final {
VerilatedFst m_sptrace; ///< Trace file being created
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedFstC);
public:
explicit VerilatedFstC(void* filep=NULL) : m_sptrace(filep) {}
explicit VerilatedFstC(void* filep = nullptr)
: m_sptrace{filep} {}
~VerilatedFstC() { close(); }
/// Routines can only be called from one thread; allow next call from different thread
void changeThread() { spTrace()->changeThread(); }
public:
// ACCESSORS
/// Is file open?
bool isOpen() const { return m_sptrace.isOpen(); }
@@ -222,13 +159,13 @@ public:
void dump(vluint32_t timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
void dump(int timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
/// Set time units (s/ms, defaults to ns)
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
/// For Verilated models, these propage from the Verilated default --timeunit
void set_time_unit(const char* unitp) { m_sptrace.set_time_unit(unitp); }
void set_time_unit(const std::string& unit) { set_time_unit(unit.c_str()); }
void set_time_unit(const std::string& unit) { m_sptrace.set_time_unit(unit); }
/// Set time resolution (s/ms, defaults to ns)
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
/// For Verilated models, these propage from the Verilated default --timeunit
void set_time_resolution(const char* unitp) { m_sptrace.set_time_resolution(unitp); }
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
void set_time_resolution(const std::string& unit) { m_sptrace.set_time_resolution(unit); }
/// Internal class access
inline VerilatedFst* spTrace() { return &m_sptrace; };
+660 -159
View File
File diff suppressed because it is too large Load Diff
+314 -129
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2009-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -19,6 +19,7 @@
#ifndef _VERILATED_IMP_H_
#define _VERILATED_IMP_H_ 1 ///< Header Guard
// clang-format off
#if !defined(_VERILATED_CPP_) && !defined(_VERILATED_DPI_CPP_) && !defined(_VERILATED_VPI_CPP_)
# error "verilated_imp.h only to be included by verilated*.cpp internals"
#endif
@@ -31,10 +32,12 @@
#include <deque>
#include <set>
#include <vector>
#include <numeric>
#ifdef VL_THREADED
# include <functional>
# include <queue>
#endif
// clang-format on
class VerilatedScope;
@@ -43,23 +46,29 @@ class VerilatedScope;
#ifdef VL_THREADED
/// Message, enqueued on an mtask, and consumed on the main eval thread
class VerilatedMsg {
class VerilatedMsg final {
public:
// TYPES
struct Cmp {
bool operator() (const VerilatedMsg& a, const VerilatedMsg& b) const {
return a.mtaskId() < b.mtaskId(); }
bool operator()(const VerilatedMsg& a, const VerilatedMsg& b) const {
return a.mtaskId() < b.mtaskId();
}
};
private:
// MEMBERS
vluint32_t m_mtaskId; ///< MTask that did enqueue
std::function<void()> m_cb; ///< Lambda to execute when message received
public:
// CONSTRUCTORS
VerilatedMsg(const std::function<void()>& cb)
: m_mtaskId(Verilated::mtaskId())
, m_cb(cb) {}
~VerilatedMsg() {}
explicit VerilatedMsg(const std::function<void()>& cb)
: m_mtaskId{Verilated::mtaskId()}
, m_cb{cb} {}
~VerilatedMsg() = default;
VerilatedMsg(const VerilatedMsg&) = default;
VerilatedMsg(VerilatedMsg&&) = default;
VerilatedMsg& operator=(const VerilatedMsg&) = default;
VerilatedMsg& operator=(VerilatedMsg&&) = default;
// METHODS
vluint32_t mtaskId() const { return m_mtaskId; }
/// Execute the lambda function
@@ -69,7 +78,7 @@ public:
/// Each thread has a queue it pushes to
/// This assumes no thread starts pushing the next tick until the previous has drained.
/// If more aggressiveness is needed, a double-buffered scheme might work well.
class VerilatedEvalMsgQueue {
class VerilatedEvalMsgQueue final {
typedef std::multiset<VerilatedMsg, VerilatedMsg::Cmp> VerilatedThreadQueue;
std::atomic<vluint64_t> m_depth; ///< Current depth of queue (see comments below)
@@ -79,18 +88,19 @@ class VerilatedEvalMsgQueue {
public:
// CONSTRUCTORS
VerilatedEvalMsgQueue()
: m_depth(0) {
: m_depth{0} {
assert(atomic_is_lock_free(&m_depth));
}
~VerilatedEvalMsgQueue() {}
~VerilatedEvalMsgQueue() = default;
private:
VL_UNCOPYABLE(VerilatedEvalMsgQueue);
public:
// METHODS
//// Add message to queue (called by producer)
void post(const VerilatedMsg& msg) VL_EXCLUDES(m_mutex) {
VerilatedLockGuard lock(m_mutex);
const VerilatedLockGuard lock(m_mutex);
m_queue.insert(msg); // Pass by value to copy the message into queue
++m_depth;
}
@@ -106,7 +116,7 @@ public:
// Unfortunately to release the lock we need to copy the message
// (Or have the message be a pointer, but then new/delete cost on each message)
// We assume messages are small, so copy
auto it = m_queue.begin();
const auto it = m_queue.begin();
const VerilatedMsg msg = *(it);
m_queue.erase(it);
m_mutex.unlock();
@@ -120,8 +130,9 @@ public:
};
/// Each thread has a local queue to build up messages until the end of the eval() call
class VerilatedThreadMsgQueue {
class VerilatedThreadMsgQueue final {
std::queue<VerilatedMsg> m_queue;
public:
// CONSTRUCTORS
VerilatedThreadMsgQueue() {}
@@ -129,6 +140,7 @@ public:
// The only call of this with a non-empty queue is a fatal error.
// So this does not flush the queue, as the destination queue is not known to this class.
}
private:
VL_UNCOPYABLE(VerilatedThreadMsgQueue);
// METHODS
@@ -136,6 +148,7 @@ private:
static VL_THREAD_LOCAL VerilatedThreadMsgQueue t_s;
return t_s;
}
public:
/// Add message to queue, called by producer
static void post(const VerilatedMsg& msg) VL_MT_SAFE {
@@ -160,11 +173,31 @@ public:
};
#endif // VL_THREADED
// FILE* list constructed from a file-descriptor
class VerilatedFpList final {
FILE* m_fp[31];
std::size_t m_sz = 0;
public:
typedef FILE* const* const_iterator;
explicit VerilatedFpList() {}
const_iterator begin() const { return m_fp; }
const_iterator end() const { return m_fp + m_sz; }
std::size_t size() const { return m_sz; }
std::size_t capacity() const { return 31; }
void push_back(FILE* fd) {
if (VL_LIKELY(size() < capacity())) m_fp[m_sz++] = fd;
}
};
//======================================================================
// VerilatedImp
class VerilatedImp {
class VerilatedImpData final {
// Whole class is internal use only - Global information shared between verilated*.cpp files.
protected:
friend class Verilated;
friend class VerilatedImp;
// TYPES
typedef std::vector<std::string> ArgVec;
@@ -172,46 +205,88 @@ class VerilatedImp {
typedef std::map<const char*, int, VerilatedCStrCmp> ExportNameMap;
// MEMBERS
static VerilatedImp s_s; ///< Static Singleton; One and only static this
// Nothing here is save-restored; users expected to re-register appropriately
struct Serialized { // All these members serialized/deserialized
int m_timeFormatUnits = UNITS_NONE; // $timeformat units
int m_timeFormatPrecision = 0; // $timeformat number of decimal places
int m_timeFormatWidth = 20; // $timeformat character width
enum { UNITS_NONE = 99 }; // Default based on precision
Serialized() = default;
~Serialized() = default;
} m_ser;
VerilatedMutex m_argMutex; ///< Protect m_argVec, m_argVecLoaded
ArgVec m_argVec VL_GUARDED_BY(m_argMutex); ///< Argument list (NOT save-restored, may want different results)
bool m_argVecLoaded VL_GUARDED_BY(m_argMutex); ///< Ever loaded argument list
VerilatedMutex m_sergMutex; ///< Protect m_ser
struct SerializedG { // All these members serialized/deserialized and guarded
std::string m_timeFormatSuffix; // $timeformat printf format
} m_serg VL_GUARDED_BY(m_sergMutex);
VerilatedMutex m_userMapMutex; ///< Protect m_userMap
UserMap m_userMap VL_GUARDED_BY(m_userMapMutex); ///< Map of <(scope,userkey), userData>
// Nothing below here is save-restored; users expected to re-register appropriately
VerilatedMutex m_nameMutex; ///< Protect m_nameMap
VerilatedScopeNameMap m_nameMap VL_GUARDED_BY(m_nameMutex); ///< Map of <scope_name, scope pointer>
VerilatedMutex m_argMutex; ///< Protect m_argVec, m_argVecLoaded
/// Argument list (NOT save-restored, may want different results)
ArgVec m_argVec VL_GUARDED_BY(m_argMutex);
bool m_argVecLoaded VL_GUARDED_BY(m_argMutex); ///< Ever loaded argument list
VerilatedMutex m_hierMapMutex; ///< Protect m_hierMap
VerilatedHierarchyMap m_hierMap VL_GUARDED_BY(m_hierMapMutex); ///< Map the represents scope hierarchy
VerilatedMutex m_userMapMutex; ///< Protect m_userMap
UserMap m_userMap VL_GUARDED_BY(m_userMapMutex); ///< Map of <(scope,userkey), userData>
VerilatedMutex m_nameMutex; ///< Protect m_nameMap
/// Map of <scope_name, scope pointer>
VerilatedScopeNameMap m_nameMap VL_GUARDED_BY(m_nameMutex);
VerilatedMutex m_hierMapMutex; ///< Protect m_hierMap
/// Map the represents scope hierarchy
VerilatedHierarchyMap m_hierMap VL_GUARDED_BY(m_hierMapMutex);
// Slow - somewhat static:
VerilatedMutex m_exportMutex; ///< Protect m_nameMap
ExportNameMap m_exportMap VL_GUARDED_BY(m_exportMutex); ///< Map of <export_func_proto, func number>
int m_exportNext VL_GUARDED_BY(m_exportMutex); ///< Next export funcnum
VerilatedMutex m_exportMutex; ///< Protect m_nameMap
/// Map of <export_func_proto, func number>
ExportNameMap m_exportMap VL_GUARDED_BY(m_exportMutex);
int m_exportNext VL_GUARDED_BY(m_exportMutex); ///< Next export funcnum
// File I/O
VerilatedMutex m_fdMutex; ///< Protect m_fdps, m_fdFree
std::vector<FILE*> m_fdps VL_GUARDED_BY(m_fdMutex); ///< File descriptors
std::deque<IData> m_fdFree VL_GUARDED_BY(m_fdMutex); ///< List of free descriptors (SLOW - FOPEN/CLOSE only)
VerilatedMutex m_fdMutex; ///< Protect m_fdps, m_fdFree
std::vector<FILE*> m_fdps VL_GUARDED_BY(m_fdMutex); ///< File descriptors
/// List of free descriptors (SLOW - FOPEN/CLOSE only)
std::vector<IData> m_fdFree VL_GUARDED_BY(m_fdMutex);
// List of free descriptors in the MCT region [4, 32)
std::vector<IData> m_fdFreeMct VL_GUARDED_BY(m_fdMutex);
// CONSTRUCTORS
VerilatedImpData()
: m_argVecLoaded{false}
, m_exportNext{0} {
m_fdps.resize(31);
std::fill(m_fdps.begin(), m_fdps.end(), (FILE*)0);
m_fdFreeMct.resize(30);
for (std::size_t i = 0, id = 1; i < m_fdFreeMct.size(); ++i, ++id) { m_fdFreeMct[i] = id; }
}
};
class VerilatedImp final {
// Whole class is internal use only - Global information shared between verilated*.cpp files.
protected:
friend class Verilated;
// MEMBERS
union VerilatedImpU { ///< Enclose in an union to call ctor/dtor manually
VerilatedImpData v;
VerilatedImpU() {} // Can't be = default;
~VerilatedImpU() {} // Can't be = default;
};
static VerilatedImpU s_s; ///< Static Singleton; One and only static this
public: // But only for verilated*.cpp
// CONSTRUCTORS
VerilatedImp()
: m_argVecLoaded(false)
, m_exportNext(0) {
m_fdps.resize(3);
m_fdps[0] = stdin;
m_fdps[1] = stdout;
m_fdps[2] = stderr;
}
~VerilatedImp() {}
VerilatedImp() = default;
~VerilatedImp() = default;
static void setup();
static void teardown();
private:
VL_UNCOPYABLE(VerilatedImp);
public:
// METHODS - debug
static void internalsDump() VL_MT_SAFE;
@@ -219,30 +294,31 @@ public:
// METHODS - arguments
public:
static void commandArgs(int argc, const char** argv) VL_EXCLUDES(s_s.m_argMutex);
static void commandArgsAdd(int argc, const char** argv) VL_EXCLUDES(s_s.m_argMutex);
static std::string argPlusMatch(const char* prefixp) VL_EXCLUDES(s_s.m_argMutex) {
VerilatedLockGuard lock(s_s.m_argMutex);
static void commandArgs(int argc, const char** argv) VL_EXCLUDES(s_s.v.m_argMutex);
static void commandArgsAdd(int argc, const char** argv) VL_EXCLUDES(s_s.v.m_argMutex);
static std::string argPlusMatch(const char* prefixp) VL_EXCLUDES(s_s.v.m_argMutex) {
const VerilatedLockGuard lock(s_s.v.m_argMutex);
// Note prefixp does not include the leading "+"
size_t len = strlen(prefixp);
if (VL_UNLIKELY(!s_s.m_argVecLoaded)) {
s_s.m_argVecLoaded = true; // Complain only once
if (VL_UNLIKELY(!s_s.v.m_argVecLoaded)) {
s_s.v.m_argVecLoaded = true; // Complain only once
VL_FATAL_MT("unknown", 0, "",
"%Error: Verilog called $test$plusargs or $value$plusargs without"
" testbench C first calling Verilated::commandArgs(argc,argv).");
}
for (ArgVec::const_iterator it = s_s.m_argVec.begin(); it != s_s.m_argVec.end(); ++it) {
if ((*it)[0] == '+') {
if (0 == strncmp(prefixp, it->c_str() + 1, len)) return *it;
for (const auto& i : s_s.v.m_argVec) {
if (i[0] == '+') {
if (0 == strncmp(prefixp, i.c_str() + 1, len)) return i;
}
}
return "";
}
private:
static void commandArgsAddGuts(int argc, const char** argv) VL_REQUIRES(s_s.m_argMutex);
static void commandArgsAddGuts(int argc, const char** argv) VL_REQUIRES(s_s.v.m_argMutex);
static void commandArgVl(const std::string& arg);
static bool commandArgVlValue(const std::string& arg,
const std::string& prefix, std::string& valuer);
static bool commandArgVlValue(const std::string& arg, const std::string& prefix,
std::string& valuer);
public:
// METHODS - user scope tracking
@@ -250,38 +326,45 @@ public:
// There's often many more scopes than userdata's and thus having a ~48byte
// per map overhead * N scopes would take much more space and cache thrashing.
static inline void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_userMapMutex);
UserMap::iterator it = s_s.m_userMap.find(std::make_pair(scopep, userKey));
if (it != s_s.m_userMap.end()) it->second = userData;
// When we support VL_THREADs, we need a lock around this insert, as it's runtime
else s_s.m_userMap.insert(it, std::make_pair(std::make_pair(scopep, userKey), userData));
const VerilatedLockGuard lock(s_s.v.m_userMapMutex);
const auto it = s_s.v.m_userMap.find(std::make_pair(scopep, userKey));
if (it != s_s.v.m_userMap.end()) {
it->second = userData;
} else {
s_s.v.m_userMap.emplace(std::make_pair(scopep, userKey), userData);
}
}
static inline void* userFind(const void* scopep, void* userKey) VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_userMapMutex);
UserMap::const_iterator it=s_s.m_userMap.find(std::make_pair(scopep, userKey));
if (VL_LIKELY(it != s_s.m_userMap.end())) return it->second;
else return NULL;
const VerilatedLockGuard lock(s_s.v.m_userMapMutex);
const auto& it = vlstd::as_const(s_s.v.m_userMap).find(std::make_pair(scopep, userKey));
if (VL_UNLIKELY(it == s_s.v.m_userMap.end())) return nullptr;
return it->second;
}
private:
/// Symbol table destruction cleans up the entries for each scope.
static void userEraseScope(const VerilatedScope* scopep) VL_MT_SAFE {
// Slow ok - called once/scope on destruction, so we simply iterate.
VerilatedLockGuard lock(s_s.m_userMapMutex);
for (UserMap::iterator it = s_s.m_userMap.begin(); it != s_s.m_userMap.end();) {
const VerilatedLockGuard lock(s_s.v.m_userMapMutex);
for (auto it = s_s.v.m_userMap.begin(); it != s_s.v.m_userMap.end();) {
if (it->first.first == scopep) {
s_s.m_userMap.erase(it++);
s_s.v.m_userMap.erase(it++);
} else {
++it;
}
}
}
static void userDump() VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_userMapMutex); // Avoid it changing in middle of dump
const VerilatedLockGuard lock(
s_s.v.m_userMapMutex); // Avoid it changing in middle of dump
bool first = true;
for (UserMap::const_iterator it=s_s.m_userMap.begin(); it!=s_s.m_userMap.end(); ++it) {
if (first) { VL_PRINTF_MT(" userDump:\n"); first=false; }
VL_PRINTF_MT(" DPI_USER_DATA scope %p key %p: %p\n",
it->first.first, it->first.second, it->second);
for (const auto& i : s_s.v.m_userMap) {
if (first) {
VL_PRINTF_MT(" userDump:\n");
first = false;
}
VL_PRINTF_MT(" DPI_USER_DATA scope %p key %p: %p\n", i.first.first, i.first.second,
i.second);
}
}
@@ -289,51 +372,58 @@ public: // But only for verilated*.cpp
// METHODS - scope name
static void scopeInsert(const VerilatedScope* scopep) VL_MT_SAFE {
// Slow ok - called once/scope at construction
VerilatedLockGuard lock(s_s.m_nameMutex);
VerilatedScopeNameMap::iterator it = s_s.m_nameMap.find(scopep->name());
if (it == s_s.m_nameMap.end()) {
s_s.m_nameMap.insert(it, std::make_pair(scopep->name(), scopep));
}
const VerilatedLockGuard lock(s_s.v.m_nameMutex);
const auto it = s_s.v.m_nameMap.find(scopep->name());
if (it == s_s.v.m_nameMap.end()) s_s.v.m_nameMap.emplace(scopep->name(), scopep);
}
static inline const VerilatedScope* scopeFind(const char* namep) VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_nameMutex);
const VerilatedLockGuard lock(s_s.v.m_nameMutex);
// If too slow, can assume this is only VL_MT_SAFE_POSINIT
VerilatedScopeNameMap::const_iterator it=s_s.m_nameMap.find(namep);
if (VL_LIKELY(it != s_s.m_nameMap.end())) return it->second;
else return NULL;
const auto& it = s_s.v.m_nameMap.find(namep);
if (VL_UNLIKELY(it == s_s.v.m_nameMap.end())) return nullptr;
return it->second;
}
static void scopeErase(const VerilatedScope* scopep) VL_MT_SAFE {
// Slow ok - called once/scope at destruction
VerilatedLockGuard lock(s_s.m_nameMutex);
const VerilatedLockGuard lock(s_s.v.m_nameMutex);
userEraseScope(scopep);
VerilatedScopeNameMap::iterator it = s_s.m_nameMap.find(scopep->name());
if (it != s_s.m_nameMap.end()) s_s.m_nameMap.erase(it);
const auto it = s_s.v.m_nameMap.find(scopep->name());
if (it != s_s.v.m_nameMap.end()) s_s.v.m_nameMap.erase(it);
}
static void scopesDump() VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_nameMutex);
const VerilatedLockGuard lock(s_s.v.m_nameMutex);
VL_PRINTF_MT(" scopesDump:\n");
for (VerilatedScopeNameMap::const_iterator it = s_s.m_nameMap.begin();
it != s_s.m_nameMap.end(); ++it) {
const VerilatedScope* scopep = it->second;
for (const auto& i : s_s.v.m_nameMap) {
const VerilatedScope* scopep = i.second;
scopep->scopeDump();
}
VL_PRINTF_MT("\n");
}
static const VerilatedScopeNameMap* scopeNameMap() VL_MT_SAFE_POSTINIT {
// Thread save only assuming this is called only after model construction completed
return &s_s.m_nameMap;
return &s_s.v.m_nameMap;
}
public: // But only for verilated*.cpp
// METHODS - hierarchy
static void hierarchyAdd(const VerilatedScope* fromp, const VerilatedScope* top) VL_MT_SAFE {
// Slow ok - called at construction for VPI accessible elements
VerilatedLockGuard lock(s_s.m_hierMapMutex);
s_s.m_hierMap[fromp].push_back(top);
const VerilatedLockGuard lock(s_s.v.m_hierMapMutex);
s_s.v.m_hierMap[fromp].push_back(top);
}
static void hierarchyRemove(const VerilatedScope* fromp,
const VerilatedScope* top) VL_MT_SAFE {
// Slow ok - called at destruction for VPI accessible elements
const VerilatedLockGuard lock(s_s.v.m_hierMapMutex);
VerilatedHierarchyMap& map = s_s.v.m_hierMap;
if (map.find(fromp) == map.end()) return;
VerilatedScopeVector& scopes = map[fromp];
const auto it = find(scopes.begin(), scopes.end(), top);
if (it != scopes.end()) scopes.erase(it);
}
static const VerilatedHierarchyMap* hierarchyMap() VL_MT_SAFE_POSTINIT {
// Thread save only assuming this is called only after model construction completed
return &s_s.m_hierMap;
return &s_s.v.m_hierMap;
}
public: // But only for verilated*.cpp
@@ -347,74 +437,169 @@ public: // But only for verilated*.cpp
// miss at the cost of a multiply, and all lookups move to slowpath.
static int exportInsert(const char* namep) VL_MT_SAFE {
// Slow ok - called once/function at creation
VerilatedLockGuard lock(s_s.m_exportMutex);
ExportNameMap::iterator it = s_s.m_exportMap.find(namep);
if (it == s_s.m_exportMap.end()) {
s_s.m_exportMap.insert(it, std::make_pair(namep, s_s.m_exportNext++));
return s_s.m_exportNext++;
const VerilatedLockGuard lock(s_s.v.m_exportMutex);
const auto it = s_s.v.m_exportMap.find(namep);
if (it == s_s.v.m_exportMap.end()) {
s_s.v.m_exportMap.emplace(namep, s_s.v.m_exportNext++);
return s_s.v.m_exportNext++;
} else {
return it->second;
}
}
static int exportFind(const char* namep) VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_exportMutex);
ExportNameMap::const_iterator it = s_s.m_exportMap.find(namep);
if (VL_LIKELY(it != s_s.m_exportMap.end())) return it->second;
std::string msg = (std::string("%Error: Testbench C called ")+namep
+" but no such DPI export function name exists in ANY model");
const VerilatedLockGuard lock(s_s.v.m_exportMutex);
const auto& it = s_s.v.m_exportMap.find(namep);
if (VL_LIKELY(it != s_s.v.m_exportMap.end())) return it->second;
std::string msg = (std::string("%Error: Testbench C called ") + namep
+ " but no such DPI export function name exists in ANY model");
VL_FATAL_MT("unknown", 0, "", msg.c_str());
return -1;
}
static const char* exportName(int funcnum) VL_MT_SAFE {
// Slowpath; find name for given export; errors only so no map to reverse-map it
VerilatedLockGuard lock(s_s.m_exportMutex);
for (ExportNameMap::const_iterator it = s_s.m_exportMap.begin();
it != s_s.m_exportMap.end(); ++it) {
if (it->second == funcnum) return it->first;
const VerilatedLockGuard lock(s_s.v.m_exportMutex);
for (const auto& i : s_s.v.m_exportMap) {
if (i.second == funcnum) return i.first;
}
return "*UNKNOWN*";
}
static void exportsDump() VL_MT_SAFE {
VerilatedLockGuard lock(s_s.m_exportMutex);
const VerilatedLockGuard lock(s_s.v.m_exportMutex);
bool first = true;
for (ExportNameMap::const_iterator it=s_s.m_exportMap.begin();
it!=s_s.m_exportMap.end(); ++it) {
if (first) { VL_PRINTF_MT(" exportDump:\n"); first=false; }
VL_PRINTF_MT(" DPI_EXPORT_NAME %05d: %s\n", it->second, it->first);
for (const auto& i : s_s.v.m_exportMap) {
if (first) {
VL_PRINTF_MT(" exportDump:\n");
first = false;
}
VL_PRINTF_MT(" DPI_EXPORT_NAME %05d: %s\n", i.second, i.first);
}
}
// We don't free up m_exportMap until the end, because we can't be sure
// what other models are using the assigned funcnum's.
public: // But only for verilated*.cpp
// METHODS - timeformat
static std::string timeFormatSuffix() VL_MT_SAFE;
static void timeFormatSuffix(const std::string& value) VL_MT_SAFE;
static int timeFormatUnits() VL_MT_SAFE {
if (s_s.v.m_ser.m_timeFormatUnits == VerilatedImpData::Serialized::UNITS_NONE) {
return Verilated::timeprecision();
}
return s_s.v.m_ser.m_timeFormatUnits;
}
static int timeFormatPrecision() VL_MT_SAFE { return s_s.v.m_ser.m_timeFormatPrecision; }
static int timeFormatWidth() VL_MT_SAFE { return s_s.v.m_ser.m_timeFormatWidth; }
static void timeFormatUnits(int value) VL_MT_SAFE;
static void timeFormatPrecision(int value) VL_MT_SAFE;
static void timeFormatWidth(int value) VL_MT_SAFE;
public: // But only for verilated*.cpp
// METHODS - file IO
static IData fdNew(FILE* fp) VL_MT_SAFE {
static IData fdNewMcd(const char* filenamep) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
if (s_s.v.m_fdFreeMct.empty()) return 0;
IData idx = s_s.v.m_fdFreeMct.back();
s_s.v.m_fdFreeMct.pop_back();
s_s.v.m_fdps[idx] = fopen(filenamep, "w");
if (VL_UNLIKELY(!s_s.v.m_fdps[idx])) return 0;
return (1 << idx);
}
static IData fdNew(const char* filenamep, const char* modep) VL_MT_SAFE {
FILE* fp = fopen(filenamep, modep);
if (VL_UNLIKELY(!fp)) return 0;
// Bit 31 indicates it's a descriptor not a MCD
VerilatedLockGuard lock(s_s.m_fdMutex);
if (s_s.m_fdFree.empty()) {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
if (s_s.v.m_fdFree.empty()) {
// Need to create more space in m_fdps and m_fdFree
size_t start = s_s.m_fdps.size();
s_s.m_fdps.resize(start*2);
for (size_t i=start; i<start*2; ++i) s_s.m_fdFree.push_back(static_cast<IData>(i));
const std::size_t start = std::max<std::size_t>(31UL + 1UL + 3UL, s_s.v.m_fdps.size());
const std::size_t excess = 10;
s_s.v.m_fdps.resize(start + excess);
std::fill(s_s.v.m_fdps.begin() + start, s_s.v.m_fdps.end(), (FILE*)0);
s_s.v.m_fdFree.resize(excess);
for (std::size_t i = 0, id = start; i < s_s.v.m_fdFree.size(); ++i, ++id) {
s_s.v.m_fdFree[i] = id;
}
}
IData idx = s_s.m_fdFree.back(); s_s.m_fdFree.pop_back();
s_s.m_fdps[idx] = fp;
return (idx | (1UL<<31)); // bit 31 indicates not MCD
IData idx = s_s.v.m_fdFree.back();
s_s.v.m_fdFree.pop_back();
s_s.v.m_fdps[idx] = fp;
return (idx | (1UL << 31)); // bit 31 indicates not MCD
}
static void fdDelete(IData fdi) VL_MT_SAFE {
IData idx = VL_MASK_I(31) & fdi;
VerilatedLockGuard lock(s_s.m_fdMutex);
if (VL_UNLIKELY(!(fdi & (VL_ULL(1) << 31)) || idx >= s_s.m_fdps.size())) return;
if (VL_UNLIKELY(!s_s.m_fdps[idx])) return; // Already free
s_s.m_fdps[idx] = NULL;
s_s.m_fdFree.push_back(idx);
static void fdFlush(IData fdi) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
const VerilatedFpList fdlist = fdToFpList(fdi);
for (const auto& i : fdlist) fflush(i);
}
static IData fdSeek(IData fdi, IData offset, IData origin) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
const VerilatedFpList fdlist = fdToFpList(fdi);
if (VL_UNLIKELY(fdlist.size() != 1)) return 0;
return static_cast<IData>(
fseek(*fdlist.begin(), static_cast<long>(offset), static_cast<int>(origin)));
}
static IData fdTell(IData fdi) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
const VerilatedFpList fdlist = fdToFpList(fdi);
if (VL_UNLIKELY(fdlist.size() != 1)) return 0;
return static_cast<IData>(ftell(*fdlist.begin()));
}
static void fdWrite(IData fdi, const std::string& output) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
const VerilatedFpList fdlist = fdToFpList(fdi);
for (const auto& i : fdlist) {
if (VL_UNLIKELY(!i)) continue;
(void)fwrite(output.c_str(), 1, output.size(), i);
}
}
static void fdClose(IData fdi) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
if ((fdi & (1 << 31)) != 0) {
// Non-MCD case
IData idx = VL_MASK_I(31) & fdi;
if (VL_UNLIKELY(idx >= s_s.v.m_fdps.size())) return;
if (VL_UNLIKELY(!s_s.v.m_fdps[idx])) return; // Already free
fclose(s_s.v.m_fdps[idx]);
s_s.v.m_fdps[idx] = (FILE*)0;
s_s.v.m_fdFree.push_back(idx);
} else {
// MCD case
for (int i = 0; (fdi != 0) && (i < 31); i++, fdi >>= 1) {
if (fdi & VL_MASK_I(1)) {
fclose(s_s.v.m_fdps[i]);
s_s.v.m_fdps[i] = nullptr;
s_s.v.m_fdFreeMct.push_back(i);
}
}
}
}
static inline FILE* fdToFp(IData fdi) VL_MT_SAFE {
IData idx = VL_MASK_I(31) & fdi;
VerilatedLockGuard lock(s_s.m_fdMutex); // This might get slow, if it does we can cache it
if (VL_UNLIKELY(!(fdi & (VL_ULL(1) << 31)) || idx >= s_s.m_fdps.size())) return NULL;
return s_s.m_fdps[idx];
const VerilatedLockGuard lock(s_s.v.m_fdMutex);
const VerilatedFpList fdlist = fdToFpList(fdi);
if (VL_UNLIKELY(fdlist.size() != 1)) return nullptr;
return *fdlist.begin();
}
private:
static inline VerilatedFpList fdToFpList(IData fdi) VL_REQUIRES(s_s.v.m_fdMutex) {
VerilatedFpList fp;
if ((fdi & (1 << 31)) != 0) {
// Non-MCD case
const IData idx = fdi & VL_MASK_I(31);
switch (idx) {
case 0: fp.push_back(stdin); break;
case 1: fp.push_back(stdout); break;
case 2: fp.push_back(stderr); break;
default:
if (VL_LIKELY(idx < s_s.v.m_fdps.size())) fp.push_back(s_s.v.m_fdps[idx]);
break;
}
} else {
// MCD Case
for (int i = 0; (fdi != 0) && (i < fp.capacity()); ++i, fdi >>= 1) {
if (fdi & VL_MASK_I(1)) fp.push_back(s_s.v.m_fdps[i]);
}
}
return fp;
}
};
+41
View File
@@ -0,0 +1,41 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
//
//*************************************************************************
///
/// \file
/// \brief Verilator: Common include for target specific intrinsics.
///
/// Code using machine specific intrinsics for optimization should
/// include this header rather than directly including he target
/// specific headers. We provide macros to check for availability
/// of instruction sets, and a common mechanism to disable them.
///
//*************************************************************************
#ifndef _VERILATED_INTRINSICS_H_
#define _VERILATED_INTRINSICS_H_ 1 ///< Header Guard
// clang-format off
// Use VL_PORTABLE_ONLY to disable all intrinsics based optimization
#ifndef VL_PORTABLE_ONLY
# if defined(__SSE2__) && !defined(VL_DISABLE_SSE2)
# define VL_HAVE_SSE2 1
# include <emmintrin.h>
# endif
# if defined(__AVX2__) && defined(VL_HAVE_SSE2) && !defined(VL_DISABLE_AVX2)
# define VL_HAVE_AVX2 1
# include <immintrin.h>
# endif
#endif
// clang-format on
#endif // Guard
+51 -41
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -23,6 +23,7 @@
#include <cerrno>
#include <fcntl.h>
// clang-format off
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# include <io.h>
#else
@@ -38,34 +39,36 @@
#ifndef O_CLOEXEC
# define O_CLOEXEC 0
#endif
// clang-format on
// CONSTANTS
static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n"; ///< Value of first bytes of each file
static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file
/// Value of first bytes of each file (must be multiple of 8 bytes)
static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n";
/// Value of last bytes of each file (must be multiple of 8 bytes)
static const char* const VLTSAVE_TRAILER_STR = "vltsaved";
//=============================================================================
//=============================================================================
//=============================================================================
// Searalization
bool VerilatedDeserialize::readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE {
bool VerilatedDeserialize::readDiffers(const void* __restrict datap,
size_t size) VL_MT_UNSAFE_ONE {
bufferCheck();
const vluint8_t* __restrict dp = static_cast<const vluint8_t* __restrict>(datap);
vluint8_t miss = 0;
while (size--) {
miss |= (*dp++ ^ *m_cp++);
}
return (miss!=0);
while (size--) miss |= (*dp++ ^ *m_cp++);
return (miss != 0);
}
VerilatedDeserialize& VerilatedDeserialize::readAssert(const void* __restrict datap,
size_t size) VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(readDiffers(datap, size))) {
std::string fn = filename();
std::string msg = "Can't deserialize save-restore file as was made from different model:"
+filename();
std::string msg = "Can't deserialize save-restore file as was made from different model: "
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
return *this; // For function chaining
}
@@ -77,19 +80,23 @@ void VerilatedSerialize::header() VL_MT_UNSAFE_ONE {
// Verilated doesn't do it itself, as if we're not using save/restore
// it doesn't need to compile this stuff in
os.write(Verilated::serializedPtr(), Verilated::serializedSize());
os.write(Verilated::serialized1Ptr(), Verilated::serialized1Size());
os.write(Verilated::serialized2Ptr(), Verilated::serialized2Size());
}
void VerilatedDeserialize::header() VL_MT_UNSAFE_ONE {
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
std::string fn = filename();
std::string msg = std::string("Can't deserialize; file has wrong header signature: ")
+filename();
std::string msg
= std::string(
"Can't deserialize; file has wrong header signature, or file not found: ")
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
os.read(Verilated::serializedPtr(), Verilated::serializedSize());
os.read(Verilated::serialized1Ptr(), Verilated::serialized1Size());
os.read(Verilated::serialized2Ptr(), Verilated::serialized2Size());
}
void VerilatedSerialize::trailer() VL_MT_UNSAFE_ONE {
@@ -103,9 +110,9 @@ void VerilatedDeserialize::trailer() VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_TRAILER_STR, strlen(VLTSAVE_TRAILER_STR)))) {
std::string fn = filename();
std::string msg = std::string("Can't deserialize; file has wrong end-of-file signature: ")
+filename();
+ filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
close();
// Die before we close() as close would infinite loop
}
}
@@ -119,13 +126,13 @@ void VerilatedSave::open(const char* filenamep) VL_MT_UNSAFE_ONE {
if (isOpen()) return;
VL_DEBUG_IF(VL_DBG_MSGF("- save: opening save file %s\n", filenamep););
if (filenamep[0]=='|') {
assert(0); // Not supported yet.
if (VL_UNCOVERABLE(filenamep[0] == '|')) {
assert(0); // LCOV_EXCL_LINE // Not supported yet.
} else {
// cppcheck-suppress duplicateExpression
m_fd = ::open(filenamep, O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK|O_CLOEXEC
, 0666);
if (m_fd<0) {
m_fd = ::open(filenamep,
O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666);
if (VL_UNLIKELY(m_fd < 0)) {
// User code can check isOpen()
m_isOpen = false;
return;
@@ -142,13 +149,12 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE {
if (isOpen()) return;
VL_DEBUG_IF(VL_DBG_MSGF("- restore: opening restore file %s\n", filenamep););
if (filenamep[0]=='|') {
assert(0); // Not supported yet.
if (VL_UNCOVERABLE(filenamep[0] == '|')) {
assert(0); // LCOV_EXCL_LINE // Not supported yet.
} else {
// cppcheck-suppress duplicateExpression
m_fd = ::open(filenamep, O_CREAT|O_RDONLY|O_LARGEFILE|O_CLOEXEC
, 0666);
if (m_fd<0) {
m_fd = ::open(filenamep, O_CREAT | O_RDONLY | O_LARGEFILE | O_CLOEXEC, 0666);
if (VL_UNLIKELY(m_fd < 0)) {
// User code can check isOpen()
m_isOpen = false;
return;
@@ -186,18 +192,20 @@ void VerilatedSave::flush() VL_MT_UNSAFE_ONE {
vluint8_t* wp = m_bufp;
while (true) {
ssize_t remaining = (m_cp - wp);
if (remaining==0) break;
if (remaining == 0) break;
errno = 0;
ssize_t got = ::write(m_fd, wp, remaining);
if (got>0) {
if (got > 0) {
wp += got;
} else if (got < 0) {
if (errno != EAGAIN && errno != EINTR) {
} else if (VL_UNCOVERABLE(got < 0)) {
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
// LCOV_EXCL_START
// write failed, presume error (perhaps out of disk space)
std::string msg = std::string(__FUNCTION__)+": "+strerror(errno);
std::string msg = std::string(__FUNCTION__) + ": " + strerror(errno);
VL_FATAL_MT("", 0, "", msg.c_str());
close();
break;
// LCOV_EXCL_STOP
}
}
}
@@ -209,29 +217,31 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(!isOpen())) return;
// Move remaining characters down to start of buffer. (No memcpy, overlaps allowed)
vluint8_t* rp = m_bufp;
for (vluint8_t* sp=m_cp; sp < m_endp;) *rp++ = *sp++; // Overlaps
for (vluint8_t* sp = m_cp; sp < m_endp; *rp++ = *sp++) {} // Overlaps
m_endp = m_bufp + (m_endp - m_cp);
m_cp = m_bufp; // Reset buffer
// Read into buffer starting at m_endp
while (true) {
ssize_t remaining = (m_bufp+bufferSize() - m_endp);
if (remaining==0) break;
ssize_t remaining = (m_bufp + bufferSize() - m_endp);
if (remaining == 0) break;
errno = 0;
ssize_t got = ::read(m_fd, m_endp, remaining);
if (got>0) {
if (got > 0) {
m_endp += got;
} else if (got < 0) {
if (errno != EAGAIN && errno != EINTR) {
} else if (VL_UNCOVERABLE(got < 0)) {
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
// LCOV_EXCL_START
// write failed, presume error (perhaps out of disk space)
std::string msg = std::string(__FUNCTION__)+": "+strerror(errno);
std::string msg = std::string(__FUNCTION__) + ": " + strerror(errno);
VL_FATAL_MT("", 0, "", msg.c_str());
close();
break;
// LCOV_EXCL_STOP
}
} else { // got==0, EOF
// Fill buffer from here to end with NULLs so reader's don't
// need to check eof each character.
while (m_endp < m_bufp+bufferSize()) *m_endp++ = '\0';
while (m_endp < m_bufp + bufferSize()) *m_endp++ = '\0';
break;
}
}
+47 -46
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2000-2020 by Wilson Snyder. This program is free software; you
// Copyright 2000-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -28,33 +28,33 @@
// VerilatedSerialize - convert structures to a stream representation
// This class is not thread safe, it must be called by a single thread
class VerilatedSerialize {
class VerilatedSerialize VL_NOT_FINAL {
protected:
// MEMBERS
// For speed, keep m_cp as the first member of this structure
vluint8_t* m_cp; ///< Current pointer into m_bufp buffer
vluint8_t* m_bufp; ///< Output buffer
bool m_isOpen; ///< True indicates open file/stream
bool m_isOpen = false; ///< True indicates open file/stream
std::string m_filename; ///< Filename, for error messages
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
inline static size_t bufferSize() { return 256 * 1024; } // See below for slack calculation
inline static size_t bufferInsertSize() { return 16 * 1024; }
static constexpr size_t bufferSize() { return 256 * 1024; } // See below for slack calculation
static constexpr size_t bufferInsertSize() { return 16 * 1024; }
void header() VL_MT_UNSAFE_ONE;
void trailer() VL_MT_UNSAFE_ONE;
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSerialize);
public:
VerilatedSerialize() {
m_isOpen = false;
m_bufp = new vluint8_t[bufferSize()];
m_cp = m_bufp;
}
virtual ~VerilatedSerialize() {
close();
if (m_bufp) { delete m_bufp; m_bufp=NULL; }
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
}
// METHODS
bool isOpen() const { return m_isOpen; }
@@ -65,20 +65,20 @@ public:
const vluint8_t* __restrict dp = (const vluint8_t* __restrict)datap;
while (size) {
bufferCheck();
size_t blk = size; if (blk>bufferInsertSize()) blk = bufferInsertSize();
size_t blk = size;
if (blk > bufferInsertSize()) blk = bufferInsertSize();
const vluint8_t* __restrict maxp = dp + blk;
while (dp < maxp) *m_cp++ = *dp++;
for (; dp < maxp; *m_cp++ = *dp++) {}
size -= blk;
}
return *this; // For function chaining
}
private:
VerilatedSerialize& bufferCheck() VL_MT_UNSAFE_ONE {
// Flush the write buffer if there's not enough space left for new information
// We only call this once per vector, so we need enough slop for a very wide "b###" line
if (VL_UNLIKELY(m_cp > (m_bufp+(bufferSize()-bufferInsertSize())))) {
flush();
}
if (VL_UNLIKELY(m_cp > (m_bufp + (bufferSize() - bufferInsertSize())))) flush();
return *this; // For function chaining
}
};
@@ -87,19 +87,19 @@ private:
// VerilatedDeserial - load structures from a stream representation
// This class is not thread safe, it must be called by a single thread
class VerilatedDeserialize {
class VerilatedDeserialize VL_NOT_FINAL {
protected:
// MEMBERS
// For speed, keep m_cp as the first member of this structure
vluint8_t* m_cp; ///< Current pointer into m_bufp buffer
vluint8_t* m_bufp; ///< Output buffer
vluint8_t* m_endp; ///< Last valid byte in m_bufp buffer
bool m_isOpen; ///< True indicates open file/stream
vluint8_t* m_endp = nullptr; ///< Last valid byte in m_bufp buffer
bool m_isOpen = false; ///< True indicates open file/stream
std::string m_filename; ///< Filename, for error messages
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
inline static size_t bufferSize() { return 256 * 1024; } // See below for slack calculation
inline static size_t bufferInsertSize() { return 16 * 1024; }
static constexpr size_t bufferSize() { return 256 * 1024; } // See below for slack calculation
static constexpr size_t bufferInsertSize() { return 16 * 1024; }
virtual void fill() = 0;
void header() VL_MT_UNSAFE_ONE;
@@ -107,16 +107,15 @@ protected:
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedDeserialize);
public:
VerilatedDeserialize() {
m_isOpen = false;
m_bufp = new vluint8_t[bufferSize()];
m_cp = m_bufp;
m_endp = NULL;
}
virtual ~VerilatedDeserialize() {
close();
if (m_bufp) { delete m_bufp; m_bufp=NULL; }
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
}
// METHODS
bool isOpen() const { return m_isOpen; }
@@ -124,12 +123,13 @@ public:
virtual void close() VL_MT_UNSAFE_ONE { flush(); }
virtual void flush() VL_MT_UNSAFE_ONE {}
inline VerilatedDeserialize& read(void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE {
vluint8_t* __restrict dp = (vluint8_t* __restrict)datap;
vluint8_t* __restrict dp = static_cast<vluint8_t* __restrict>(datap);
while (size) {
bufferCheck();
size_t blk = size; if (blk>bufferInsertSize()) blk = bufferInsertSize();
size_t blk = size;
if (blk > bufferInsertSize()) blk = bufferInsertSize();
const vluint8_t* __restrict maxp = dp + blk;
while (dp < maxp) *dp++ = *m_cp++;
for (; dp < maxp; *dp++ = *m_cp++) {}
size -= blk;
}
return *this; // For function chaining
@@ -137,15 +137,15 @@ public:
// Read a datum and compare with expected value
VerilatedDeserialize& readAssert(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
VerilatedDeserialize& readAssert(vluint64_t data) VL_MT_UNSAFE_ONE {
return readAssert(&data, sizeof(data)); }
return readAssert(&data, sizeof(data));
}
private:
bool readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
VerilatedDeserialize& bufferCheck() VL_MT_UNSAFE_ONE {
// Flush the write buffer if there's not enough space left for new information
// We only call this once per vector, so we need enough slop for a very wide "b###" line
if (VL_UNLIKELY((m_cp+bufferInsertSize()) > m_endp)) {
fill();
}
if (VL_UNLIKELY((m_cp + bufferInsertSize()) > m_endp)) fill();
return *this; // For function chaining
}
};
@@ -154,40 +154,42 @@ private:
// VerilatedSave - serialize to a file
// This class is not thread safe, it must be called by a single thread
class VerilatedSave : public VerilatedSerialize {
class VerilatedSave final : public VerilatedSerialize {
private:
int m_fd; ///< File descriptor we're writing to
int m_fd = -1; ///< File descriptor we're writing to
public:
// CONSTRUCTORS
VerilatedSave() { m_fd = -1; }
virtual ~VerilatedSave() VL_OVERRIDE { close(); }
VerilatedSave() = default;
virtual ~VerilatedSave() override { close(); }
// METHODS
void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
/// Open the file; call isOpen() to see if errors
void open(const char* filenamep) VL_MT_UNSAFE_ONE;
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE;
virtual void close() override VL_MT_UNSAFE_ONE;
virtual void flush() override VL_MT_UNSAFE_ONE;
};
//=============================================================================
// VerilatedRestore - deserialize from a file
// This class is not thread safe, it must be called by a single thread
class VerilatedRestore : public VerilatedDeserialize {
class VerilatedRestore final : public VerilatedDeserialize {
private:
int m_fd; ///< File descriptor we're writing to
int m_fd = -1; ///< File descriptor we're writing to
public:
// CONSTRUCTORS
VerilatedRestore() { m_fd = -1; }
virtual ~VerilatedRestore() VL_OVERRIDE { close(); }
VerilatedRestore() = default;
virtual ~VerilatedRestore() override { close(); }
// METHODS
void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
/// Open the file; call isOpen() to see if errors
void open(const char* filenamep) VL_MT_UNSAFE_ONE;
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE {}
virtual void fill() VL_OVERRIDE VL_MT_UNSAFE_ONE;
virtual void close() override VL_MT_UNSAFE_ONE;
virtual void flush() override VL_MT_UNSAFE_ONE {}
virtual void fill() override VL_MT_UNSAFE_ONE;
};
//=============================================================================
@@ -250,10 +252,9 @@ VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray<T_Key, T_Val
os << rhs.atDefault();
vluint32_t len = rhs.size();
os << len;
for (typename VlAssocArray<T_Key, T_Value>::const_iterator it = rhs.begin();
it != rhs.end(); ++it) {
T_Key index = it->first; // Copy to get around const_iterator
T_Value value = it->second;
for (const auto& i : rhs) {
T_Key index = i.first; // Copy to get around const_iterator
T_Value value = i.second;
os << index << value;
}
return os;
+2 -2
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2009-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -34,7 +34,7 @@
// This class is thread safe (though most of SystemC is not).
#define VL_SC_BV_DATAP(bv) (VlScBvExposer::sp_datap(bv))
class VlScBvExposer : public sc_bv_base {
class VlScBvExposer final : public sc_bv_base {
public:
static const vluint32_t* sp_datap(const sc_bv_base& base) VL_MT_SAFE {
return static_cast<const VlScBvExposer*>(&base)->sp_datatp();
+110 -86
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -29,28 +29,38 @@
#include "verilatedos.h"
#include <vector>
//===========================================================================
/// Verilator range
/// Thread safety: Assume is constructed only with model, then any number of readers
// See also V3Ast::VNumRange
class VerilatedRange {
int m_left;
int m_right;
class VerilatedRange final {
int m_left = 0;
int m_right = 0;
protected:
friend class VerilatedVarProps;
friend class VerilatedScope;
VerilatedRange() : m_left(0), m_right(0) {}
VerilatedRange(int left, int right) : m_left(left), m_right(right) {}
void init(int left, int right) { m_left=left; m_right=right; }
VerilatedRange() = default;
void init(int left, int right) {
m_left = left;
m_right = right;
}
public:
~VerilatedRange() {}
VerilatedRange(int left, int right)
: m_left{left}
, m_right{right} {}
~VerilatedRange() = default;
int left() const { return m_left; }
int right() const { return m_right; }
int low() const { return (m_left < m_right) ? m_left : m_right; }
int high() const { return (m_left > m_right) ? m_left : m_right; }
int elements() const {
return (VL_LIKELY(m_left>=m_right) ? (m_left-m_right+1) : (m_right-m_left+1)); }
return (VL_LIKELY(m_left >= m_right) ? (m_left - m_right + 1) : (m_right - m_left + 1));
}
int increment() const { return (m_left >= m_right) ? 1 : -1; }
};
@@ -58,75 +68,81 @@ public:
/// Verilator variable
/// Thread safety: Assume is constructed only with model, then any number of readers
class VerilatedVarProps {
class VerilatedVarProps VL_NOT_FINAL {
// TYPES
enum { MAGIC = 0xddc4f829 };
// MEMBERS
const vluint32_t m_magic; // Magic number
const VerilatedVarType m_vltype; // Data type
const VerilatedVarFlags m_vlflags; // Direction
const int m_pdims; // Packed dimensions
const int m_udims; // Unpacked dimensions
VerilatedRange m_packed; // Packed array range
VerilatedRange m_unpacked[3]; // Unpacked array range
const vluint32_t m_magic; // Magic number
const VerilatedVarType m_vltype; // Data type
const VerilatedVarFlags m_vlflags; // Direction
const int m_pdims; // Packed dimensions, 0 = none
const int m_udims; // Unpacked dimensions, 0 = none
VerilatedRange m_packed; // Packed array range
std::vector<VerilatedRange> m_unpacked; // Unpacked array ranges
void initUnpacked(const int* ulims) {
for (int i = 0; i < m_udims; ++i) {
const int uleft = ulims ? ulims[2 * i + 0] : 0;
const int uright = ulims ? ulims[2 * i + 1] : 0;
m_unpacked.emplace_back(uleft, uright);
}
}
// CONSTRUCTORS
protected:
friend class VerilatedScope;
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags,
int pdims, int udims)
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(vlflags), m_pdims(pdims), m_udims(udims) {}
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags, int pdims, int udims)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags{vlflags}
, m_pdims{pdims}
, m_udims{udims} {
initUnpacked(nullptr);
}
public:
class Unpacked {};
// Without packed
VerilatedVarProps(VerilatedVarType vltype, int vlflags)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(0) { }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Unpacked, int u0l, int u0r)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(1) {
m_unpacked[0].init(u0l, u0r); }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Unpacked, int u0l, int u0r, int u1l, int u1r)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(2) {
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(3) {
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); m_unpacked[2].init(u2l, u2r); }
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags(VerilatedVarFlags(vlflags)) // Need () or GCC 4.8 false warning
, m_pdims{0}
, m_udims{0} {}
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Unpacked, int udims, const int* ulims)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags(VerilatedVarFlags(vlflags)) // Need () or GCC 4.8 false warning
, m_pdims{0}
, m_udims{udims} {
initUnpacked(ulims);
}
// With packed
class Packed {};
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Packed, int pl, int pr)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(0), m_packed(pl,pr) { }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Packed, int pl, int pr,
Unpacked, int u0l, int u0r)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(1), m_packed(pl,pr) {
m_unpacked[0].init(u0l, u0r); }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Packed, int pl, int pr,
Unpacked, int u0l, int u0r, int u1l, int u1r)
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(VerilatedVarFlags(vlflags)),
m_pdims(1), m_udims(2), m_packed(pl,pr) {
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); }
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
Packed, int pl, int pr,
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
: m_magic(MAGIC), m_vltype(vltype),
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(3), m_packed(pl,pr) {
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); m_unpacked[2].init(u2l, u2r); }
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Packed, int pl, int pr)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags(VerilatedVarFlags(vlflags)) // Need () or GCC 4.8 false warning
, m_pdims{1}
, m_udims{0}
, m_packed{pl, pr} {}
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Packed, int pl, int pr, Unpacked,
int udims, const int* ulims)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags(VerilatedVarFlags(vlflags)) // Need () or GCC 4.8 false warning
, m_pdims{1}
, m_udims{udims}
, m_packed{pl, pr} {
initUnpacked(ulims);
}
public:
~VerilatedVarProps() {}
~VerilatedVarProps() = default;
// METHODS
bool magicOk() const { return m_magic == MAGIC; }
VerilatedVarType vltype() const { return m_vltype; }
VerilatedVarFlags vldir() const {
return static_cast<VerilatedVarFlags>(static_cast<int>(m_vlflags) & VLVF_MASK_DIR); }
return static_cast<VerilatedVarFlags>(static_cast<int>(m_vlflags) & VLVF_MASK_DIR);
}
vluint32_t entSize() const;
bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); }
/// DPI compatible C standard layout
@@ -137,28 +153,30 @@ public:
const VerilatedRange& unpacked() const { return m_unpacked[0]; }
// DPI accessors
int left(int dim) const {
return dim==0 ? m_packed.left()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].left() : 0;
return dim == 0 ? m_packed.left()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].left() : 0;
}
int right(int dim) const {
return dim==0 ? m_packed.right()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].right() : 0;
return dim == 0 ? m_packed.right()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].right() : 0;
}
int low(int dim) const {
return dim==0 ? m_packed.low()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].low() : 0;
return dim == 0 ? m_packed.low()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].low() : 0;
}
int high(int dim) const {
return dim==0 ? m_packed.high()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].high() : 0;
return dim == 0 ? m_packed.high()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].high() : 0;
}
int increment(int dim) const {
return dim==0 ? m_packed.increment()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].increment() : 0;
return dim == 0
? m_packed.increment()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].increment() : 0;
}
int elements(int dim) const {
return dim==0 ? m_packed.elements()
: VL_LIKELY(dim>=1 && dim<=3) ? m_unpacked[dim-1].elements() : 0;
return dim == 0
? m_packed.elements()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].elements() : 0;
}
/// Total size in bytes (note DPI limited to 4GB)
size_t totalSize() const;
@@ -169,19 +187,19 @@ public:
//===========================================================================
/// Verilator DPI open array variable
class VerilatedDpiOpenVar {
class VerilatedDpiOpenVar final {
// MEMBERS
const VerilatedVarProps* m_propsp; // Variable properties
void* m_datap; // Location of data (local to thread always, so safe)
public:
// CONSTRUCTORS
VerilatedDpiOpenVar(const VerilatedVarProps* propsp, void* datap)
: m_propsp(propsp)
, m_datap(datap) {}
: m_propsp{propsp}
, m_datap{datap} {}
VerilatedDpiOpenVar(const VerilatedVarProps* propsp, const void* datap)
: m_propsp(propsp)
, m_datap(const_cast<void*>(datap)) {}
~VerilatedDpiOpenVar() {}
: m_propsp{propsp}
, m_datap{const_cast<void*>(datap)} {}
~VerilatedDpiOpenVar() = default;
// METHODS
void* datap() const { return m_datap; }
// METHODS - from VerilatedVarProps
@@ -199,31 +217,37 @@ public:
int elements(int dim) const { return m_propsp->elements(dim); }
size_t totalSize() const { return m_propsp->totalSize(); }
void* datapAdjustIndex(void* datap, int dim, int indx) const {
return m_propsp->datapAdjustIndex(datap, dim, indx); }
return m_propsp->datapAdjustIndex(datap, dim, indx);
}
};
//===========================================================================
/// Verilator variable
/// Thread safety: Assume is constructed only with model, then any number of readers
class VerilatedVar : public VerilatedVarProps {
class VerilatedVar final : public VerilatedVarProps {
// MEMBERS
void* m_datap; // Location of data
const char* m_namep; // Name - slowpath
protected:
bool m_isParam;
friend class VerilatedScope;
// CONSTRUCTORS
VerilatedVar(const char* namep, void* datap,
VerilatedVarType vltype, VerilatedVarFlags vlflags, int dims)
: VerilatedVarProps(vltype, vlflags, (dims>0?1:0), ((dims>1)?dims-1:0))
, m_datap(datap), m_namep(namep) {}
VerilatedVar(const char* namep, void* datap, VerilatedVarType vltype,
VerilatedVarFlags vlflags, int dims, bool isParam)
: VerilatedVarProps{vltype, vlflags, (dims > 0 ? 1 : 0), ((dims > 1) ? dims - 1 : 0)}
, m_datap{datap}
, m_namep{namep}
, m_isParam{isParam} {}
public:
~VerilatedVar() {}
~VerilatedVar() = default;
// ACCESSORS
void* datap() const { return m_datap; }
const VerilatedRange& range() const { return packed(); } // Deprecated
const VerilatedRange& array() const { return unpacked(); } // Deprecated
const char* name() const { return m_namep; }
bool isParam() const { return m_isParam; }
};
#endif // Guard
+12 -10
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -31,6 +31,7 @@
#include "verilated_sym_props.h"
#include <map>
#include <unordered_map>
#include <vector>
//======================================================================
@@ -42,26 +43,27 @@ struct VerilatedCStrCmp {
};
/// Map of sorted scope names to find associated scope class
class VerilatedScopeNameMap
class VerilatedScopeNameMap final
: public std::map<const char*, const VerilatedScope*, VerilatedCStrCmp> {
public:
VerilatedScopeNameMap() {}
~VerilatedScopeNameMap() {}
VerilatedScopeNameMap() = default;
~VerilatedScopeNameMap() = default;
};
/// Map of sorted variable names to find associated variable class
class VerilatedVarNameMap : public std::map<const char*, VerilatedVar, VerilatedCStrCmp> {
class VerilatedVarNameMap final : public std::map<const char*, VerilatedVar, VerilatedCStrCmp> {
public:
VerilatedVarNameMap() {}
~VerilatedVarNameMap() {}
VerilatedVarNameMap() = default;
~VerilatedVarNameMap() = default;
};
typedef std::vector<const VerilatedScope*> VerilatedScopeVector;
class VerilatedHierarchyMap : public std::map<const VerilatedScope*, VerilatedScopeVector> {
class VerilatedHierarchyMap final
: public std::unordered_map<const VerilatedScope*, VerilatedScopeVector> {
public:
VerilatedHierarchyMap() {}
~VerilatedHierarchyMap() {}
VerilatedHierarchyMap() = default;
~VerilatedHierarchyMap() = default;
};
#endif // Guard
+46 -72
View File
@@ -1,7 +1,7 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// Copyright 2012-2020 by Wilson Snyder. This program is free software; you can
// Copyright 2012-2021 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -21,14 +21,14 @@
std::atomic<vluint64_t> VlMTaskVertex::s_yields;
VL_THREAD_LOCAL VlThreadPool::ProfileTrace* VlThreadPool::t_profilep = NULL;
VL_THREAD_LOCAL VlThreadPool::ProfileTrace* VlThreadPool::t_profilep = nullptr;
//=============================================================================
// VlMTaskVertex
VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
: m_upstreamDepsDone(0),
m_upstreamDepCount(upstreamDepCount) {
: m_upstreamDepsDone{0}
, m_upstreamDepCount{upstreamDepCount} {
assert(atomic_is_lock_free(&m_upstreamDepsDone));
}
@@ -36,13 +36,11 @@ VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
// VlWorkerThread
VlWorkerThread::VlWorkerThread(VlThreadPool* poolp, bool profiling)
: m_waiting(false)
, m_ready_size(0)
, m_poolp(poolp)
, m_profiling(profiling)
, m_exiting(false)
// Must init this last -- after setting up fields that it might read:
, m_cthread(startWorker, this) {}
: m_waiting{false}
, m_poolp{poolp}
, m_profiling{profiling} // Must init this last -- after setting up fields that it might read:
, m_exiting{false}
, m_cthread{startWorker, this} {}
VlWorkerThread::~VlWorkerThread() {
m_exiting.store(true, std::memory_order_release);
@@ -52,77 +50,63 @@ VlWorkerThread::~VlWorkerThread() {
}
void VlWorkerThread::workerLoop() {
if (VL_UNLIKELY(m_profiling)) {
m_poolp->setupProfilingClientThread();
}
if (VL_UNLIKELY(m_profiling)) m_poolp->setupProfilingClientThread();
ExecRec work;
work.m_fnp = NULL;
work.m_fnp = nullptr;
while (true) {
if (VL_LIKELY(!work.m_fnp)) {
dequeWork(&work);
}
if (VL_LIKELY(!work.m_fnp)) dequeWork(&work);
// Do this here, not above, to avoid a race with the destructor.
if (VL_UNLIKELY(m_exiting.load(std::memory_order_acquire)))
break;
if (VL_UNLIKELY(m_exiting.load(std::memory_order_acquire))) break;
if (VL_LIKELY(work.m_fnp)) {
work.m_fnp(work.m_evenCycle, work.m_sym);
work.m_fnp = NULL;
work.m_fnp = nullptr;
}
}
if (VL_UNLIKELY(m_profiling)) {
m_poolp->tearDownProfilingClientThread();
}
if (VL_UNLIKELY(m_profiling)) m_poolp->tearDownProfilingClientThread();
}
void VlWorkerThread::startWorker(VlWorkerThread* workerp) {
workerp->workerLoop();
}
void VlWorkerThread::startWorker(VlWorkerThread* workerp) { workerp->workerLoop(); }
//=============================================================================
// VlThreadPool
VlThreadPool::VlThreadPool(int nThreads, bool profiling)
: m_profiling(profiling) {
: m_profiling{profiling} {
// --threads N passes nThreads=N-1, as the "main" threads counts as 1
unsigned cpus = std::thread::hardware_concurrency();
if (cpus < nThreads+1) {
if (cpus < nThreads + 1) {
static int warnedOnce = 0;
if (!warnedOnce++) {
VL_PRINTF_MT("%%Warning: System has %u CPUs but model Verilated with"
" --threads %d; may run slow.\n", cpus, nThreads+1);
" --threads %d; may run slow.\n",
cpus, nThreads + 1);
}
}
// Create'em
for (int i=0; i<nThreads; ++i) {
for (int i = 0; i < nThreads; ++i) {
m_workers.push_back(new VlWorkerThread(this, profiling));
}
// Set up a profile buffer for the current thread too -- on the
// assumption that it's the same thread that calls eval and may be
// donated to run mtasks during the eval.
if (VL_UNLIKELY(m_profiling)) {
setupProfilingClientThread();
}
if (VL_UNLIKELY(m_profiling)) setupProfilingClientThread();
}
VlThreadPool::~VlThreadPool() {
for (int i = 0; i < m_workers.size(); ++i) {
// Each ~WorkerThread will wait for its thread to exit.
delete m_workers[i];
}
if (VL_UNLIKELY(m_profiling)) {
tearDownProfilingClientThread();
}
// Each ~WorkerThread will wait for its thread to exit.
for (auto& i : m_workers) delete i;
if (VL_UNLIKELY(m_profiling)) tearDownProfilingClientThread();
}
void VlThreadPool::tearDownProfilingClientThread() {
assert(t_profilep);
delete t_profilep;
t_profilep = NULL;
t_profilep = nullptr;
}
void VlThreadPool::setupProfilingClientThread() {
@@ -132,73 +116,63 @@ void VlThreadPool::setupProfilingClientThread() {
// try not to malloc while collecting profiling.
t_profilep->reserve(4096);
{
VerilatedLockGuard lk(m_mutex);
const VerilatedLockGuard lk(m_mutex);
m_allProfiles.insert(t_profilep);
}
}
void VlThreadPool::profileAppendAll(const VlProfileRec& rec) {
VerilatedLockGuard lk(m_mutex);
for (ProfileSet::iterator it = m_allProfiles.begin();
it != m_allProfiles.end(); ++it) {
const VerilatedLockGuard lk(m_mutex);
for (const auto& profilep : m_allProfiles) {
// Every thread's profile trace gets a copy of rec.
(*it)->emplace_back(rec);
profilep->emplace_back(rec);
}
}
void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
VerilatedLockGuard lk(m_mutex);
const VerilatedLockGuard lk(m_mutex);
VL_DEBUG_IF(VL_DBG_MSGF("+prof+threads writing to '%s'\n", filenamep););
FILE* fp = fopen(filenamep, "w");
if (VL_UNLIKELY(!fp)) {
VL_FATAL_MT(filenamep, 0, "", "+prof+threads+file file not writable");
return;
// cppcheck-suppress resourceLeak // bug, doesn't realize fp is nullptr
return; // LCOV_EXCL_LINE
}
// TODO Perhaps merge with verilated_coverage output format, so can
// have a common merging and reporting tool, etc.
fprintf(fp, "VLPROFTHREAD 1.0 # Verilator thread profile dump version 1.0\n");
fprintf(fp, "VLPROF arg --threads %" VL_PRI64 "u\n",
vluint64_t(m_workers.size()+1));
fprintf(fp, "VLPROF arg --threads %" VL_PRI64 "u\n", vluint64_t(m_workers.size() + 1));
fprintf(fp, "VLPROF arg +verilator+prof+threads+start+%" VL_PRI64 "u\n",
Verilated::profThreadsStart());
fprintf(fp, "VLPROF arg +verilator+prof+threads+window+%u\n",
Verilated::profThreadsWindow());
fprintf(fp, "VLPROF stat yields %" VL_PRI64 "u\n",
VlMTaskVertex::yields());
fprintf(fp, "VLPROF arg +verilator+prof+threads+window+%u\n", Verilated::profThreadsWindow());
fprintf(fp, "VLPROF stat yields %" VL_PRI64 "u\n", VlMTaskVertex::yields());
vluint32_t thread_id = 0;
for (ProfileSet::const_iterator pit = m_allProfiles.begin();
pit != m_allProfiles.end(); ++pit) {
for (const auto& pi : m_allProfiles) {
++thread_id;
bool printing = false; // False while in warmup phase
for (ProfileTrace::const_iterator eit = (*pit)->begin();
eit != (*pit)->end(); ++eit) {
switch (eit->m_type) {
case VlProfileRec::TYPE_BARRIER:
for (const auto& ei : *pi) {
switch (ei.m_type) {
case VlProfileRec::TYPE_BARRIER: //
printing = true;
break;
case VlProfileRec::TYPE_MTASK_RUN:
if (!printing) break;
fprintf(fp, "VLPROF mtask %d"
" start %" VL_PRI64"u end %" VL_PRI64"u elapsed %" VL_PRI64 "u"
fprintf(fp,
"VLPROF mtask %d"
" start %" VL_PRI64 "u end %" VL_PRI64 "u elapsed %" VL_PRI64 "u"
" predict_time %u cpu %u on thread %u\n",
eit->m_mtaskId,
eit->m_startTime,
eit->m_endTime,
(eit->m_endTime - eit->m_startTime),
eit->m_predictTime,
eit->m_cpu,
thread_id);
ei.m_mtaskId, ei.m_startTime, ei.m_endTime,
(ei.m_endTime - ei.m_startTime), ei.m_predictTime, ei.m_cpu, thread_id);
break;
default: assert(false); break; // LCOV_EXCL_LINE
}
}
}
fprintf(fp, "VLPROF stat ticks %" VL_PRI64 "u\n",
ticksElapsed);
fprintf(fp, "VLPROF stat ticks %" VL_PRI64 "u\n", ticksElapsed);
fclose(fp);
}
+37 -29
View File
@@ -3,7 +3,7 @@
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2012-2020 by Wilson Snyder. This program is free software; you
// Copyright 2012-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
@@ -22,15 +22,27 @@
#include "verilatedos.h"
#include "verilated.h" // for VerilatedMutex and clang annotations
#ifndef VL_THREADED
// Hitting this likely means verilated_threads.cpp is being compiled when
// 'verilator --threads' was not used. 'verilator --threads' sets
// VL_THREADED.
// Alternatively it is always safe but may harm performance to always
// define VL_THREADED for all compiles.
#error "verilated_threads.h/cpp expected VL_THREADED (from verilator --threads)"
#endif
#include <condition_variable>
#include <set>
#include <vector>
// clang-format off
#if defined(__linux)
#include <sched.h> // For sched_getcpu()
# include <sched.h> // For sched_getcpu()
#endif
#if defined(__APPLE__)
# include <cpuid.h> // For __cpuid_count()
#endif
// clang-format on
// VlMTaskVertex and VlThreadpool will work with multiple symbol table types.
// Since the type is opaque to VlMTaskVertex and VlThreadPool, represent it
@@ -40,7 +52,7 @@ typedef void* VlThrSymTab;
typedef void (*VlExecFnp)(bool, VlThrSymTab);
/// Track dependencies for a single MTask.
class VlMTaskVertex {
class VlMTaskVertex final {
// MEMBERS
static std::atomic<vluint64_t> s_yields; // Statistics
@@ -70,7 +82,7 @@ public:
// that must notify this MTaskVertex before it will become ready
// to run.
explicit VlMTaskVertex(vluint32_t upstreamDepCount);
~VlMTaskVertex() {}
~VlMTaskVertex() = default;
static vluint64_t yields() { return s_yields; }
static void yieldThread() {
@@ -112,30 +124,20 @@ public:
};
// Profiling support
class VlProfileRec {
class VlProfileRec final {
protected:
friend class VlThreadPool;
enum VlProfileE {
TYPE_MTASK_RUN,
TYPE_BARRIER
};
VlProfileE m_type; // Record type
vluint32_t m_mtaskId; // Mtask we're logging
vluint32_t m_predictTime; // How long scheduler predicted would take
vluint64_t m_startTime; // Tick at start of execution
vluint64_t m_endTime; // Tick at end of execution
enum VlProfileE { TYPE_MTASK_RUN, TYPE_BARRIER };
VlProfileE m_type = TYPE_BARRIER; // Record type
vluint32_t m_mtaskId = 0; // Mtask we're logging
vluint32_t m_predictTime = 0; // How long scheduler predicted would take
vluint64_t m_startTime = 0; // Tick at start of execution
vluint64_t m_endTime = 0; // Tick at end of execution
unsigned m_cpu; // Execution CPU number (at start anyways)
public:
class Barrier {};
VlProfileRec() {}
explicit VlProfileRec(Barrier) {
m_type = TYPE_BARRIER;
m_mtaskId = 0;
m_predictTime = 0;
m_startTime = 0;
m_endTime = 0;
m_cpu = getcpu();
}
VlProfileRec() = default;
explicit VlProfileRec(Barrier) { m_cpu = getcpu(); }
void startRecord(vluint64_t time, uint32_t mtask, uint32_t predict) {
m_type = VlProfileRec::TYPE_MTASK_RUN;
m_mtaskId = mtask;
@@ -166,16 +168,21 @@ public:
class VlThreadPool;
class VlWorkerThread {
class VlWorkerThread final {
private:
// TYPES
struct ExecRec {
VlExecFnp m_fnp; // Function to execute
VlThrSymTab m_sym; // Symbol table to execute
bool m_evenCycle; // Even/odd for flag alternation
ExecRec() : m_fnp(NULL), m_sym(NULL), m_evenCycle(false) {}
ExecRec()
: m_fnp{nullptr}
, m_sym{nullptr}
, m_evenCycle{false} {}
ExecRec(VlExecFnp fnp, bool evenCycle, VlThrSymTab sym)
: m_fnp(fnp), m_sym(sym), m_evenCycle(evenCycle) {}
: m_fnp{fnp}
, m_sym{sym}
, m_evenCycle{evenCycle} {}
};
// MEMBERS
@@ -208,7 +215,7 @@ public:
inline void dequeWork(ExecRec* workp) {
// Spin for a while, waiting for new data
for (int i = 0; i < VL_LOCK_SPINS; ++i) {
if (VL_LIKELY(m_ready_size.load(std::memory_order_relaxed))) {
if (VL_LIKELY(m_ready_size.load(std::memory_order_relaxed))) { //
break;
}
VL_CPU_RELAX();
@@ -229,7 +236,7 @@ public:
inline void addTask(VlExecFnp fnp, bool evenCycle, VlThrSymTab sym) {
bool notify;
{
VerilatedLockGuard lk(m_mutex);
const VerilatedLockGuard lk(m_mutex);
m_ready.emplace_back(fnp, evenCycle, sym);
m_ready_size.fetch_add(1, std::memory_order_relaxed);
notify = m_waiting;
@@ -240,7 +247,7 @@ public:
static void startWorker(VlWorkerThread* workerp);
};
class VlThreadPool {
class VlThreadPool final {
// TYPES
typedef std::vector<VlProfileRec> ProfileTrace;
typedef std::set<ProfileTrace*> ProfileSet;
@@ -284,6 +291,7 @@ public:
// this once to setup profiling state:
void setupProfilingClientThread();
void tearDownProfilingClientThread();
private:
VL_UNCOPYABLE(VlThreadPool);
};
+402
View File
@@ -0,0 +1,402 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
//
//=============================================================================
///
/// \file
/// \brief Tracing functionality common to all formats
///
//=============================================================================
// SPDIFF_OFF
#ifndef _VERILATED_TRACE_H_
#define _VERILATED_TRACE_H_ 1
// clang-format off
#include "verilated.h"
#include <string>
#include <vector>
#ifdef VL_TRACE_THREADED
# include <condition_variable>
# include <deque>
# include <thread>
#endif
// clang-format on
#ifdef VL_TRACE_THREADED
//=============================================================================
// Threaded tracing
// A simple synchronized first in first out queue
template <class T> class VerilatedThreadQueue final { // LCOV_EXCL_LINE // lcov bug
private:
VerilatedMutex m_mutex; // Protects m_queue
std::condition_variable_any m_cv;
std::deque<T> m_queue VL_GUARDED_BY(m_mutex);
public:
// Put an element at the back of the queue
void put(T value) {
VerilatedLockGuard lock(m_mutex);
m_queue.push_back(value);
m_cv.notify_one();
}
// Put an element at the front of the queue
void put_front(T value) {
VerilatedLockGuard lock(m_mutex);
m_queue.push_front(value);
m_cv.notify_one();
}
// Get an element from the front of the queue. Blocks if none available
T get() {
VerilatedLockGuard lock(m_mutex);
m_cv.wait(lock, [this]() VL_REQUIRES(m_mutex) { return !m_queue.empty(); });
assert(!m_queue.empty());
T value = m_queue.front();
m_queue.pop_front();
return value;
}
// Non blocking get
bool tryGet(T& result) {
const VerilatedLockGuard lockGuard(m_mutex);
if (m_queue.empty()) { return false; }
result = m_queue.front();
m_queue.pop_front();
return true;
}
};
// Commands used by thread tracing. Anonymous enum in class, as we want
// it scoped, but we also want the automatic conversion to integer types.
class VerilatedTraceCommand final {
public:
// These must all fit in 4 bit at the moment, as the tracing routines
// pack parameters in the top bits.
enum : vluint8_t {
CHG_BIT_0 = 0x0,
CHG_BIT_1 = 0x1,
CHG_CDATA = 0x2,
CHG_SDATA = 0x3,
CHG_IDATA = 0x4,
CHG_QDATA = 0x5,
CHG_WDATA = 0x6,
CHG_DOUBLE = 0x8,
// TODO: full..
TIME_CHANGE = 0xd,
END = 0xe, // End of buffer
SHUTDOWN = 0xf // Shutdown worker thread, also marks end of buffer
};
};
#endif
//=============================================================================
// VerilatedTrace
// VerilatedTrace uses F-bounded polymorphism to access duck-typed
// implementations in the format specific derived class, which must be passed
// as the type parameter T_Derived
template <class T_Derived> class VerilatedTrace VL_NOT_FINAL {
public:
//=========================================================================
// Generic tracing internals
typedef void (*initCb_t)(void*, T_Derived*, uint32_t); // Type of init callbacks
typedef void (*dumpCb_t)(void*, T_Derived*); // Type of all but init callbacks
private:
struct CallbackRecord {
// Note: would make these fields const, but some old STL implementations
// (the one in Ubuntu 14.04 with GCC 4.8.4 in particular) use the
// assignment operator on inserting into collections, so they don't work
// with const fields...
union {
initCb_t m_initCb; // The callback function
dumpCb_t m_dumpCb; // The callback function
};
void* m_userp; // The user pointer to pass to the callback (the symbol table)
CallbackRecord(initCb_t cb, void* userp)
: m_initCb{cb}
, m_userp{userp} {}
CallbackRecord(dumpCb_t cb, void* userp)
: m_dumpCb{cb}
, m_userp{userp} {}
};
vluint32_t* m_sigs_oldvalp; ///< Old value store
vluint64_t m_timeLastDump; ///< Last time we did a dump
std::vector<CallbackRecord> m_initCbs; ///< Routines to initialize traciong
std::vector<CallbackRecord> m_fullCbs; ///< Routines to perform full dump
std::vector<CallbackRecord> m_chgCbs; ///< Routines to perform incremental dump
std::vector<CallbackRecord> m_cleanupCbs; ///< Routines to call at the end of dump
bool m_fullDump; ///< Whether a full dump is required on the next call to 'dump'
vluint32_t m_nextCode; ///< Next code number to assign
vluint32_t m_numSignals; ///< Number of distinct signals
vluint32_t m_maxBits; ///< Number of bits in the widest signal
std::string m_moduleName; ///< Name of module being trace initialized now
char m_scopeEscape;
double m_timeRes; ///< Time resolution (ns/ms etc)
double m_timeUnit; ///< Time units (ns/ms etc)
void addCallbackRecord(std::vector<CallbackRecord>& cbVec, CallbackRecord& cbRec);
// Equivalent to 'this' but is of the sub-type 'T_Derived*'. Use 'self()->'
// to access duck-typed functions to avoid a virtual function call.
T_Derived* self() { return static_cast<T_Derived*>(this); }
// Flush any remaining data for this file
static void onFlush(void* selfp) VL_MT_UNSAFE_ONE;
// Close the file on termination
static void onExit(void* selfp) VL_MT_UNSAFE_ONE;
#ifdef VL_TRACE_THREADED
// Number of total trace buffers that have been allocated
vluint32_t m_numTraceBuffers;
// Size of trace buffers
size_t m_traceBufferSize;
// Buffers handed to worker for processing
VerilatedThreadQueue<vluint32_t*> m_buffersToWorker;
// Buffers returned from worker after processing
VerilatedThreadQueue<vluint32_t*> m_buffersFromWorker;
// Get a new trace buffer that can be populated. May block if none available
vluint32_t* getTraceBuffer();
// Write pointer into current buffer
vluint32_t* m_traceBufferWritep;
// End of trace buffer
vluint32_t* m_traceBufferEndp;
// The worker thread itself
std::unique_ptr<std::thread> m_workerThread;
// The function executed by the worker thread
void workerThreadMain();
// Wait until given buffer is placed in m_buffersFromWorker
void waitForBuffer(const vluint32_t* bufferp);
// Shut down and join worker, if it's running, otherwise do nothing
void shutdownWorker();
#endif
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedTrace);
protected:
//=========================================================================
// Internals available to format specific implementations
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
vluint32_t nextCode() const { return m_nextCode; }
vluint32_t numSignals() const { return m_numSignals; }
vluint32_t maxBits() const { return m_maxBits; }
const std::string& moduleName() const { return m_moduleName; }
void fullDump(bool value) { m_fullDump = value; }
vluint64_t timeLastDump() { return m_timeLastDump; }
double timeRes() const { return m_timeRes; }
double timeUnit() const { return m_timeUnit; }
std::string timeResStr() const;
void traceInit() VL_MT_UNSAFE;
void declCode(vluint32_t code, vluint32_t bits, bool tri);
/// Is this an escape?
bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; }
/// Character that splits scopes. Note whitespace are ALWAYS escapes.
char scopeEscape() { return m_scopeEscape; }
void close();
void flush();
//=========================================================================
// Virtual functions to be provided by the format specific implementation
// Called when the trace moves forward to a new time point
virtual void emitTimeChange(vluint64_t timeui) = 0;
// These hooks are called before a full or change based dump is produced.
// The return value indicates whether to proceed with the dump.
virtual bool preFullDump() = 0;
virtual bool preChangeDump() = 0;
public:
//=========================================================================
// External interface to client code
explicit VerilatedTrace();
~VerilatedTrace();
// Set time units (s/ms, defaults to ns)
void set_time_unit(const char* unitp);
void set_time_unit(const std::string& unit);
// Set time resolution (s/ms, defaults to ns)
void set_time_resolution(const char* unitp);
void set_time_resolution(const std::string& unit);
// Call
void dump(vluint64_t timeui);
//=========================================================================
// Non-hot path internal interface to Verilator generated code
void addInitCb(initCb_t cb, void* userp) VL_MT_UNSAFE_ONE;
void addFullCb(dumpCb_t cb, void* userp) VL_MT_UNSAFE_ONE;
void addChgCb(dumpCb_t cb, void* userp) VL_MT_UNSAFE_ONE;
void addCleanupCb(dumpCb_t cb, void* userp) VL_MT_UNSAFE_ONE;
void changeThread() { m_assertOne.changeThread(); }
void module(const std::string& name) VL_MT_UNSAFE_ONE {
m_assertOne.check();
m_moduleName = name;
}
void scopeEscape(char flag) { m_scopeEscape = flag; }
//=========================================================================
// Hot path internal interface to Verilator generated code
// Implementation note: We rely on the following duck-typed implementations
// in the derived class T_Derived. These emit* functions record a format
// specific trace entry. Normally one would use pure virtual functions for
// these here, but we cannot afford dynamic dispatch for calling these as
// this is very hot code during tracing.
// duck-typed void emitBit(vluint32_t code, CData newval) = 0;
// duck-typed void emitCData(vluint32_t code, CData newval, int bits) = 0;
// duck-typed void emitSData(vluint32_t code, SData newval, int bits) = 0;
// duck-typed void emitIData(vluint32_t code, IData newval, int bits) = 0;
// duck-typed void emitQData(vluint32_t code, QData newval, int bits) = 0;
// duck-typed void emitWData(vluint32_t code, const WData* newvalp, int bits) = 0;
// duck-typed void emitDouble(vluint32_t code, double newval) = 0;
vluint32_t* oldp(vluint32_t code) { return m_sigs_oldvalp + code; }
// Write to previous value buffer value and emit trace entry.
void fullBit(vluint32_t* oldp, CData newval);
void fullCData(vluint32_t* oldp, CData newval, int bits);
void fullSData(vluint32_t* oldp, SData newval, int bits);
void fullIData(vluint32_t* oldp, IData newval, int bits);
void fullQData(vluint32_t* oldp, QData newval, int bits);
void fullWData(vluint32_t* oldp, const WData* newvalp, int bits);
void fullDouble(vluint32_t* oldp, double newval);
#ifdef VL_TRACE_THREADED
// Threaded tracing. Just dump everything in the trace buffer
inline void chgBit(vluint32_t code, CData newval) {
m_traceBufferWritep[0] = VerilatedTraceCommand::CHG_BIT_0 | newval;
m_traceBufferWritep[1] = code;
m_traceBufferWritep += 2;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgCData(vluint32_t code, CData newval, int bits) {
m_traceBufferWritep[0] = (bits << 4) | VerilatedTraceCommand::CHG_CDATA;
m_traceBufferWritep[1] = code;
m_traceBufferWritep[2] = newval;
m_traceBufferWritep += 3;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgSData(vluint32_t code, SData newval, int bits) {
m_traceBufferWritep[0] = (bits << 4) | VerilatedTraceCommand::CHG_SDATA;
m_traceBufferWritep[1] = code;
m_traceBufferWritep[2] = newval;
m_traceBufferWritep += 3;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgIData(vluint32_t code, IData newval, int bits) {
m_traceBufferWritep[0] = (bits << 4) | VerilatedTraceCommand::CHG_IDATA;
m_traceBufferWritep[1] = code;
m_traceBufferWritep[2] = newval;
m_traceBufferWritep += 3;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgQData(vluint32_t code, QData newval, int bits) {
m_traceBufferWritep[0] = (bits << 4) | VerilatedTraceCommand::CHG_QDATA;
m_traceBufferWritep[1] = code;
*reinterpret_cast<QData*>(m_traceBufferWritep + 2) = newval;
m_traceBufferWritep += 4;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgWData(vluint32_t code, const WData* newvalp, int bits) {
m_traceBufferWritep[0] = (bits << 4) | VerilatedTraceCommand::CHG_WDATA;
m_traceBufferWritep[1] = code;
m_traceBufferWritep += 2;
for (int i = 0; i < (bits + 31) / 32; ++i) { *m_traceBufferWritep++ = newvalp[i]; }
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
inline void chgDouble(vluint32_t code, double newval) {
m_traceBufferWritep[0] = VerilatedTraceCommand::CHG_DOUBLE;
m_traceBufferWritep[1] = code;
// cppcheck-suppress invalidPointerCast
*reinterpret_cast<double*>(m_traceBufferWritep + 2) = newval;
m_traceBufferWritep += 4;
VL_DEBUG_IF(assert(m_traceBufferWritep <= m_traceBufferEndp););
}
#define CHG(name) chg##name##Impl
#else
#define CHG(name) chg##name
#endif
// In non-threaded mode, these are called directly by the trace callbacks,
// and are called chg*. In threaded mode, they are called by the worker
// thread and are called chg*Impl
// Check previous dumped value of signal. If changed, then emit trace entry
inline void CHG(Bit)(vluint32_t* oldp, CData newval) {
const vluint32_t diff = *oldp ^ newval;
if (VL_UNLIKELY(diff)) fullBit(oldp, newval);
}
inline void CHG(CData)(vluint32_t* oldp, CData newval, int bits) {
const vluint32_t diff = *oldp ^ newval;
if (VL_UNLIKELY(diff)) fullCData(oldp, newval, bits);
}
inline void CHG(SData)(vluint32_t* oldp, SData newval, int bits) {
const vluint32_t diff = *oldp ^ newval;
if (VL_UNLIKELY(diff)) fullSData(oldp, newval, bits);
}
inline void CHG(IData)(vluint32_t* oldp, IData newval, int bits) {
const vluint32_t diff = *oldp ^ newval;
if (VL_UNLIKELY(diff)) fullIData(oldp, newval, bits);
}
inline void CHG(QData)(vluint32_t* oldp, QData newval, int bits) {
const vluint64_t diff = *reinterpret_cast<QData*>(oldp) ^ newval;
if (VL_UNLIKELY(diff)) fullQData(oldp, newval, bits);
}
inline void CHG(WData)(vluint32_t* oldp, const WData* newvalp, int bits) {
for (int i = 0; i < (bits + 31) / 32; ++i) {
if (VL_UNLIKELY(oldp[i] ^ newvalp[i])) {
fullWData(oldp, newvalp, bits);
return;
}
}
}
inline void CHG(Double)(vluint32_t* oldp, double newval) {
// cppcheck-suppress invalidPointerCast
if (VL_UNLIKELY(*reinterpret_cast<double*>(oldp) != newval)) fullDouble(oldp, newval);
}
#undef CHG
};
#endif // guard
+677
View File
@@ -0,0 +1,677 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
//
// Copyright 2001-2021 by Wilson Snyder. This program is free software; you
// can redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
//
//=============================================================================
///
/// \file
/// \brief Implementation of tracing functionality common to all trace formats
///
//=============================================================================
// SPDIFF_OFF
// clang-format off
#ifndef VL_CPPCHECK
#ifndef VL_DERIVED_T
# error "This file should be included in trace format implementations"
#endif
#include "verilated_intrinsics.h"
#include "verilated_trace.h"
#if 0
# include <iostream>
# define VL_TRACE_THREAD_DEBUG(msg) std::cout << "TRACE THREAD: " << msg << std::endl
#else
# define VL_TRACE_THREAD_DEBUG(msg)
#endif
// clang-format on
//=============================================================================
// Static utility functions
static double timescaleToDouble(const char* unitp) {
char* endp = nullptr;
double value = strtod(unitp, &endp);
// On error so we allow just "ns" to return 1e-9.
if (value == 0.0 && endp == unitp) value = 1;
unitp = endp;
for (; *unitp && isspace(*unitp); unitp++) {}
switch (*unitp) {
case 's': value *= 1e0; break;
case 'm': value *= 1e-3; break;
case 'u': value *= 1e-6; break;
case 'n': value *= 1e-9; break;
case 'p': value *= 1e-12; break;
case 'f': value *= 1e-15; break;
case 'a': value *= 1e-18; break;
}
return value;
}
static std::string doubleToTimescale(double value) {
const char* suffixp = "s";
// clang-format off
if (value >= 1e0) { suffixp = "s"; value *= 1e0; }
else if (value >= 1e-3 ) { suffixp = "ms"; value *= 1e3; }
else if (value >= 1e-6 ) { suffixp = "us"; value *= 1e6; }
else if (value >= 1e-9 ) { suffixp = "ns"; value *= 1e9; }
else if (value >= 1e-12) { suffixp = "ps"; value *= 1e12; }
else if (value >= 1e-15) { suffixp = "fs"; value *= 1e15; }
else if (value >= 1e-18) { suffixp = "as"; value *= 1e18; }
// clang-format on
char valuestr[100];
sprintf(valuestr, "%0.0f%s", value, suffixp);
return valuestr; // Gets converted to string, so no ref to stack
}
#ifdef VL_TRACE_THREADED
//=========================================================================
// Buffer management
template <> vluint32_t* VerilatedTrace<VL_DERIVED_T>::getTraceBuffer() {
vluint32_t* bufferp;
// Some jitter is expected, so some number of alternative trace buffers are
// required, but don't allocate more than 8 buffers.
if (m_numTraceBuffers < 8) {
// Allocate a new buffer if none is available
if (!m_buffersFromWorker.tryGet(bufferp)) {
++m_numTraceBuffers;
// Note: over allocate a bit so pointer comparison is well defined
// if we overflow only by a small amount
bufferp = new vluint32_t[m_traceBufferSize + 16];
}
} else {
// Block until a buffer becomes available
bufferp = m_buffersFromWorker.get();
}
return bufferp;
}
template <> void VerilatedTrace<VL_DERIVED_T>::waitForBuffer(const vluint32_t* buffp) {
// Slow path code only called on flush/shutdown, so use a simple algorithm.
// Collect buffers from worker and stash them until we get the one we want.
std::deque<vluint32_t*> stash;
do { stash.push_back(m_buffersFromWorker.get()); } while (stash.back() != buffp);
// Now put them back in the queue, in the original order.
while (!stash.empty()) {
m_buffersFromWorker.put_front(stash.back());
stash.pop_back();
}
}
//=========================================================================
// Worker thread
template <> void VerilatedTrace<VL_DERIVED_T>::workerThreadMain() {
bool shutdown = false;
do {
vluint32_t* const bufferp = m_buffersToWorker.get();
VL_TRACE_THREAD_DEBUG("");
VL_TRACE_THREAD_DEBUG("Got buffer: " << bufferp);
const vluint32_t* readp = bufferp;
while (true) {
const vluint32_t cmd = readp[0];
const vluint32_t top = cmd >> 4;
// Always set this up, as it is almost always needed
vluint32_t* const oldp = m_sigs_oldvalp + readp[1];
// Note this increment needs to be undone on commands which do not
// actually contain a code, but those are the rare cases.
readp += 2;
switch (cmd & 0xF) {
//===
// CHG_* commands
case VerilatedTraceCommand::CHG_BIT_0:
VL_TRACE_THREAD_DEBUG("Command CHG_BIT_0 " << top);
chgBitImpl(oldp, 0);
continue;
case VerilatedTraceCommand::CHG_BIT_1:
VL_TRACE_THREAD_DEBUG("Command CHG_BIT_1 " << top);
chgBitImpl(oldp, 1);
continue;
case VerilatedTraceCommand::CHG_CDATA:
VL_TRACE_THREAD_DEBUG("Command CHG_CDATA " << top);
// Bits stored in bottom byte of command
chgCDataImpl(oldp, *readp, top);
readp += 1;
continue;
case VerilatedTraceCommand::CHG_SDATA:
VL_TRACE_THREAD_DEBUG("Command CHG_SDATA " << top);
// Bits stored in bottom byte of command
chgSDataImpl(oldp, *readp, top);
readp += 1;
continue;
case VerilatedTraceCommand::CHG_IDATA:
VL_TRACE_THREAD_DEBUG("Command CHG_IDATA " << top);
// Bits stored in bottom byte of command
chgIDataImpl(oldp, *readp, top);
readp += 1;
continue;
case VerilatedTraceCommand::CHG_QDATA:
VL_TRACE_THREAD_DEBUG("Command CHG_QDATA " << top);
// Bits stored in bottom byte of command
chgQDataImpl(oldp, *reinterpret_cast<const QData*>(readp), top);
readp += 2;
continue;
case VerilatedTraceCommand::CHG_WDATA:
VL_TRACE_THREAD_DEBUG("Command CHG_WDATA " << top);
chgWDataImpl(oldp, readp, top);
readp += VL_WORDS_I(top);
continue;
case VerilatedTraceCommand::CHG_DOUBLE:
VL_TRACE_THREAD_DEBUG("Command CHG_DOUBLE " << top);
chgDoubleImpl(oldp, *reinterpret_cast<const double*>(readp));
readp += 2;
continue;
//===
// Rare commands
case VerilatedTraceCommand::TIME_CHANGE:
VL_TRACE_THREAD_DEBUG("Command TIME_CHANGE " << top);
readp -= 1; // No code in this command, undo increment
emitTimeChange(*reinterpret_cast<const vluint64_t*>(readp));
readp += 2;
continue;
//===
// Commands ending this buffer
case VerilatedTraceCommand::END: VL_TRACE_THREAD_DEBUG("Command END"); break;
case VerilatedTraceCommand::SHUTDOWN:
VL_TRACE_THREAD_DEBUG("Command SHUTDOWN");
shutdown = true;
break;
//===
// Unknown command
default: { // LCOV_EXCL_START
VL_TRACE_THREAD_DEBUG("Command UNKNOWN");
VL_PRINTF_MT("Trace command: 0x%08x\n", cmd);
VL_FATAL_MT(__FILE__, __LINE__, "", "Unknown trace command");
break;
} // LCOV_EXCL_STOP
}
// The above switch will execute 'continue' when necessary,
// so if we ever reach here, we are done with the buffer.
break;
}
VL_TRACE_THREAD_DEBUG("Returning buffer");
// Return buffer
m_buffersFromWorker.put(bufferp);
} while (VL_LIKELY(!shutdown));
}
template <> void VerilatedTrace<VL_DERIVED_T>::shutdownWorker() {
// If the worker thread is not running, done..
if (!m_workerThread) return;
// Hand an buffer with a shutdown command to the worker thread
vluint32_t* const bufferp = getTraceBuffer();
bufferp[0] = VerilatedTraceCommand::SHUTDOWN;
m_buffersToWorker.put(bufferp);
// Wait for it to return
waitForBuffer(bufferp);
// Join the thread and delete it
m_workerThread->join();
m_workerThread.reset(nullptr);
}
#endif
//=============================================================================
// Life cycle
template <> void VerilatedTrace<VL_DERIVED_T>::close() {
#ifdef VL_TRACE_THREADED
shutdownWorker();
while (m_numTraceBuffers) {
delete[] m_buffersFromWorker.get();
m_numTraceBuffers--;
}
#endif
}
template <> void VerilatedTrace<VL_DERIVED_T>::flush() {
#ifdef VL_TRACE_THREADED
// Hand an empty buffer to the worker thread
vluint32_t* const bufferp = getTraceBuffer();
*bufferp = VerilatedTraceCommand::END;
m_buffersToWorker.put(bufferp);
// Wait for it to be returned. As the processing is in-order,
// this ensures all previous buffers have been processed.
waitForBuffer(bufferp);
#endif
}
//=============================================================================
// Callbacks to run on global events
template <> void VerilatedTrace<VL_DERIVED_T>::onFlush(void* selfp) {
// Note this calls 'flush' on the derived class
reinterpret_cast<VL_DERIVED_T*>(selfp)->flush();
}
template <> void VerilatedTrace<VL_DERIVED_T>::onExit(void* selfp) {
// Note this calls 'close' on the derived class
reinterpret_cast<VL_DERIVED_T*>(selfp)->close();
}
//=============================================================================
// VerilatedTrace
template <>
VerilatedTrace<VL_DERIVED_T>::VerilatedTrace()
: m_sigs_oldvalp{nullptr}
, m_timeLastDump{0}
, m_fullDump{true}
, m_nextCode{0}
, m_numSignals{0}
, m_maxBits{0}
, m_scopeEscape{'.'}
, m_timeRes{1e-9}
, m_timeUnit {
1e-9
}
#ifdef VL_TRACE_THREADED
, m_numTraceBuffers { 0 }
#endif
{
set_time_unit(Verilated::timeunitString());
set_time_resolution(Verilated::timeprecisionString());
}
template <> VerilatedTrace<VL_DERIVED_T>::~VerilatedTrace() {
if (m_sigs_oldvalp) VL_DO_CLEAR(delete[] m_sigs_oldvalp, m_sigs_oldvalp = nullptr);
Verilated::removeFlushCb(VerilatedTrace<VL_DERIVED_T>::onFlush, this);
Verilated::removeExitCb(VerilatedTrace<VL_DERIVED_T>::onExit, this);
#ifdef VL_TRACE_THREADED
close();
#endif
}
//=========================================================================
// Internals available to format specific implementations
template <> void VerilatedTrace<VL_DERIVED_T>::traceInit() VL_MT_UNSAFE {
m_assertOne.check();
// Note: It is possible to re-open a trace file (VCD in particular),
// so we must reset the next code here, but it must have the same number
// of codes on re-open
const vluint32_t expectedCodes = nextCode();
m_nextCode = 1;
m_numSignals = 0;
m_maxBits = 0;
// Call all initialize callbacks, which will:
// - Call decl* for each signal
// - Store the base code
for (vluint32_t i = 0; i < m_initCbs.size(); ++i) {
const CallbackRecord& cbr = m_initCbs[i];
cbr.m_initCb(cbr.m_userp, self(), nextCode());
}
if (expectedCodes && nextCode() != expectedCodes) {
VL_FATAL_MT(__FILE__, __LINE__, "",
"Reopening trace file with different number of signals");
}
// Now that we know the number of codes, allocate space for the buffer
// holding previous signal values.
if (!m_sigs_oldvalp) m_sigs_oldvalp = new vluint32_t[nextCode()];
// Set callback so flush/abort will flush this file
Verilated::addFlushCb(VerilatedTrace<VL_DERIVED_T>::onFlush, this);
Verilated::addExitCb(VerilatedTrace<VL_DERIVED_T>::onExit, this);
#ifdef VL_TRACE_THREADED
// Compute trace buffer size. we need to be able to store a new value for
// each signal, which is 'nextCode()' entries after the init callbacks
// above have been run, plus up to 2 more words of metadata per signal,
// plus fixed overhead of 1 for a termination flag and 3 for a time stamp
// update.
m_traceBufferSize = nextCode() + numSignals() * 2 + 4;
// Start the worker thread
m_workerThread.reset(new std::thread(&VerilatedTrace<VL_DERIVED_T>::workerThreadMain, this));
#endif
}
template <>
void VerilatedTrace<VL_DERIVED_T>::declCode(vluint32_t code, vluint32_t bits, bool tri) {
if (!code) {
VL_FATAL_MT(__FILE__, __LINE__, "", "Internal: internal trace problem, code 0 is illegal");
}
// Note: The tri-state flag is not used by Verilator, but is here for
// compatibility with some foreign code.
int codesNeeded = VL_WORDS_I(bits);
if (tri) codesNeeded *= 2;
m_nextCode = std::max(m_nextCode, code + codesNeeded);
++m_numSignals;
m_maxBits = std::max(m_maxBits, bits);
}
//=========================================================================
// Internals available to format specific implementations
template <> std::string VerilatedTrace<VL_DERIVED_T>::timeResStr() const {
return doubleToTimescale(m_timeRes);
}
//=========================================================================
// External interface to client code
template <> void VerilatedTrace<VL_DERIVED_T>::set_time_unit(const char* unitp) {
m_timeUnit = timescaleToDouble(unitp);
}
template <> void VerilatedTrace<VL_DERIVED_T>::set_time_unit(const std::string& unit) {
set_time_unit(unit.c_str());
}
template <> void VerilatedTrace<VL_DERIVED_T>::set_time_resolution(const char* unitp) {
m_timeRes = timescaleToDouble(unitp);
}
template <> void VerilatedTrace<VL_DERIVED_T>::set_time_resolution(const std::string& unit) {
set_time_resolution(unit.c_str());
}
template <> void VerilatedTrace<VL_DERIVED_T>::dump(vluint64_t timeui) {
m_assertOne.check();
if (VL_UNCOVERABLE(m_timeLastDump && timeui <= m_timeLastDump)) { // LCOV_EXCL_START
VL_PRINTF_MT("%%Warning: previous dump at t=%" VL_PRI64 "u, requesting t=%" VL_PRI64
"u, dump call ignored\n",
m_timeLastDump, timeui);
return;
} // LCOV_EXCL_STOP
m_timeLastDump = timeui;
Verilated::quiesce();
// Call hook for format specific behaviour
if (VL_UNLIKELY(m_fullDump)) {
if (!preFullDump()) return;
} else {
if (!preChangeDump()) return;
}
#ifdef VL_TRACE_THREADED
// Currently only incremental dumps run on the worker thread
vluint32_t* bufferp = nullptr;
if (VL_LIKELY(!m_fullDump)) {
// Get the trace buffer we are about to fill
bufferp = getTraceBuffer();
m_traceBufferWritep = bufferp;
m_traceBufferEndp = bufferp + m_traceBufferSize;
// Tell worker to update time point
m_traceBufferWritep[0] = VerilatedTraceCommand::TIME_CHANGE;
*reinterpret_cast<vluint64_t*>(m_traceBufferWritep + 1) = timeui;
m_traceBufferWritep += 3;
} else {
// Update time point
flush();
emitTimeChange(timeui);
}
#else
// Update time point
emitTimeChange(timeui);
#endif
// Run the callbacks
if (VL_UNLIKELY(m_fullDump)) {
m_fullDump = false; // No more need for next dump to be full
for (vluint32_t i = 0; i < m_fullCbs.size(); ++i) {
const CallbackRecord& cbr = m_fullCbs[i];
cbr.m_dumpCb(cbr.m_userp, self());
}
} else {
for (vluint32_t i = 0; i < m_chgCbs.size(); ++i) {
const CallbackRecord& cbr = m_chgCbs[i];
cbr.m_dumpCb(cbr.m_userp, self());
}
}
for (vluint32_t i = 0; i < m_cleanupCbs.size(); ++i) {
const CallbackRecord& cbr = m_cleanupCbs[i];
cbr.m_dumpCb(cbr.m_userp, self());
}
#ifdef VL_TRACE_THREADED
if (VL_LIKELY(bufferp)) {
// Mark end of the trace buffer we just filled
*m_traceBufferWritep++ = VerilatedTraceCommand::END;
// Assert no buffer overflow
assert(m_traceBufferWritep - bufferp <= m_traceBufferSize);
// Pass it to the worker thread
m_buffersToWorker.put(bufferp);
}
#endif
}
//=============================================================================
// Non-hot path internal interface to Verilator generated code
template <>
void VerilatedTrace<VL_DERIVED_T>::addCallbackRecord(std::vector<CallbackRecord>& cbVec,
CallbackRecord& cbRec) {
m_assertOne.check();
if (VL_UNCOVERABLE(timeLastDump() != 0)) { // LCOV_EXCL_START
std::string msg = (std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
+ " called with already open file");
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
} // LCOV_EXCL_STOP
cbVec.push_back(cbRec);
}
template <> void VerilatedTrace<VL_DERIVED_T>::addInitCb(initCb_t cb, void* userp) {
CallbackRecord cbr(cb, userp);
addCallbackRecord(m_initCbs, cbr);
}
template <> void VerilatedTrace<VL_DERIVED_T>::addFullCb(dumpCb_t cb, void* userp) {
CallbackRecord cbr(cb, userp);
addCallbackRecord(m_fullCbs, cbr);
}
template <> void VerilatedTrace<VL_DERIVED_T>::addChgCb(dumpCb_t cb, void* userp) {
CallbackRecord cbr(cb, userp);
addCallbackRecord(m_chgCbs, cbr);
}
template <> void VerilatedTrace<VL_DERIVED_T>::addCleanupCb(dumpCb_t cb, void* userp) {
CallbackRecord cbr(cb, userp);
addCallbackRecord(m_cleanupCbs, cbr);
}
//=========================================================================
// Hot path internal interface to Verilator generated code
// These functions must write the new value back into the old value store,
// and subsequently call the format specific emit* implementations. Note
// that this file must be included in the format specific implementation, so
// the emit* functions can be inlined for performance.
template <> void VerilatedTrace<VL_DERIVED_T>::fullBit(vluint32_t* oldp, CData newval) {
*oldp = newval;
self()->emitBit(oldp - m_sigs_oldvalp, newval);
}
template <>
void VerilatedTrace<VL_DERIVED_T>::fullCData(vluint32_t* oldp, CData newval, int bits) {
*oldp = newval;
self()->emitCData(oldp - m_sigs_oldvalp, newval, bits);
}
template <>
void VerilatedTrace<VL_DERIVED_T>::fullSData(vluint32_t* oldp, SData newval, int bits) {
*oldp = newval;
self()->emitSData(oldp - m_sigs_oldvalp, newval, bits);
}
template <>
void VerilatedTrace<VL_DERIVED_T>::fullIData(vluint32_t* oldp, IData newval, int bits) {
*oldp = newval;
self()->emitIData(oldp - m_sigs_oldvalp, newval, bits);
}
template <>
void VerilatedTrace<VL_DERIVED_T>::fullQData(vluint32_t* oldp, QData newval, int bits) {
*reinterpret_cast<QData*>(oldp) = newval;
self()->emitQData(oldp - m_sigs_oldvalp, newval, bits);
}
template <>
void VerilatedTrace<VL_DERIVED_T>::fullWData(vluint32_t* oldp, const WData* newvalp, int bits) {
for (int i = 0; i < VL_WORDS_I(bits); ++i) oldp[i] = newvalp[i];
self()->emitWData(oldp - m_sigs_oldvalp, newvalp, bits);
}
template <> void VerilatedTrace<VL_DERIVED_T>::fullDouble(vluint32_t* oldp, double newval) {
// cppcheck-suppress invalidPointerCast
*reinterpret_cast<double*>(oldp) = newval;
self()->emitDouble(oldp - m_sigs_oldvalp, newval);
}
//=========================================================================
// Primitives converting binary values to strings...
// All of these take a destination pointer where the string will be emitted,
// and a value to convert. There are a couple of variants for efficiency.
static inline void cvtCDataToStr(char* dstp, CData value) {
#ifdef VL_HAVE_SSE2
// Similar to cvtSDataToStr but only the bottom 8 byte lanes are used
const __m128i a = _mm_cvtsi32_si128(value);
const __m128i b = _mm_unpacklo_epi8(a, a);
const __m128i c = _mm_shufflelo_epi16(b, 0);
const __m128i m = _mm_set1_epi64x(0x0102040810204080);
const __m128i d = _mm_cmpeq_epi8(_mm_and_si128(c, m), m);
const __m128i result = _mm_sub_epi8(_mm_set1_epi8('0'), d);
_mm_storel_epi64(reinterpret_cast<__m128i*>(dstp), result);
#else
dstp[0] = '0' | static_cast<char>((value >> 7) & 1);
dstp[1] = '0' | static_cast<char>((value >> 6) & 1);
dstp[2] = '0' | static_cast<char>((value >> 5) & 1);
dstp[3] = '0' | static_cast<char>((value >> 4) & 1);
dstp[4] = '0' | static_cast<char>((value >> 3) & 1);
dstp[5] = '0' | static_cast<char>((value >> 2) & 1);
dstp[6] = '0' | static_cast<char>((value >> 1) & 1);
dstp[7] = '0' | static_cast<char>(value & 1);
#endif
}
static inline void cvtSDataToStr(char* dstp, SData value) {
#ifdef VL_HAVE_SSE2
// We want each bit in the 16-bit input value to end up in a byte lane
// within the 128-bit XMM register. Note that x86 is little-endian and we
// want the MSB of the input at the low address, so we will bit-reverse
// at the same time.
// Put value in bottom of 128-bit register a[15:0] = value
const __m128i a = _mm_cvtsi32_si128(value);
// Interleave bytes with themselves
// b[15: 0] = {2{a[ 7:0]}} == {2{value[ 7:0]}}
// b[31:16] = {2{a[15:8]}} == {2{value[15:8]}}
const __m128i b = _mm_unpacklo_epi8(a, a);
// Shuffle bottom 64 bits, note swapping high bytes with low bytes
// c[31: 0] = {2{b[31:16]}} == {4{value[15:8}}
// c[63:32] = {2{b[15: 0]}} == {4{value[ 7:0}}
const __m128i c = _mm_shufflelo_epi16(b, 0x05);
// Shuffle whole register
// d[ 63: 0] = {2{c[31: 0]}} == {8{value[15:8}}
// d[126:54] = {2{c[63:32]}} == {8{value[ 7:0}}
const __m128i d = _mm_shuffle_epi32(c, 0x50);
// Test each bit within the bytes, this sets each byte lane to 0
// if the bit for that lane is 0 and to 0xff if the bit is 1.
const __m128i m = _mm_set1_epi64x(0x0102040810204080);
const __m128i e = _mm_cmpeq_epi8(_mm_and_si128(d, m), m);
// Convert to ASCII by subtracting the masks from ASCII '0':
// '0' - 0 is '0', '0' - -1 is '1'
const __m128i result = _mm_sub_epi8(_mm_set1_epi8('0'), e);
// Store the 16 characters to the un-aligned buffer
_mm_storeu_si128(reinterpret_cast<__m128i*>(dstp), result);
#else
cvtCDataToStr(dstp, value >> 8);
cvtCDataToStr(dstp + 8, value);
#endif
}
static inline void cvtIDataToStr(char* dstp, IData value) {
#ifdef VL_HAVE_AVX2
// Similar to cvtSDataToStr but the bottom 16-bits are processed in the
// top half of the YMM registerss
const __m256i a = _mm256_insert_epi32(_mm256_undefined_si256(), value, 0);
const __m256i b = _mm256_permute4x64_epi64(a, 0);
const __m256i s = _mm256_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3);
const __m256i c = _mm256_shuffle_epi8(b, s);
const __m256i m = _mm256_set1_epi64x(0x0102040810204080);
const __m256i d = _mm256_cmpeq_epi8(_mm256_and_si256(c, m), m);
const __m256i result = _mm256_sub_epi8(_mm256_set1_epi8('0'), d);
_mm256_storeu_si256(reinterpret_cast<__m256i*>(dstp), result);
#else
cvtSDataToStr(dstp, value >> 16);
cvtSDataToStr(dstp + 16, value);
#endif
}
static inline void cvtQDataToStr(char* dstp, QData value) {
cvtIDataToStr(dstp, value >> 32);
cvtIDataToStr(dstp + 32, value);
}
#define cvtEDataToStr cvtIDataToStr
//=============================================================================
#ifdef VERILATED_VCD_TEST
void verilated_trace_imp_selftest() {
#define SELF_CHECK(got, exp) \
do { \
if ((got) != (exp)) VL_FATAL_MT(__FILE__, __LINE__, "", "%Error: selftest\n"); \
} while (0)
#define SELF_CHECK_TS(scale) \
SELF_CHECK(doubleToTimescale(timescaleToDouble(scale)), std::string{scale});
SELF_CHECK_TS("1s");
SELF_CHECK_TS("100ms");
SELF_CHECK_TS("10ms");
SELF_CHECK_TS("1ms");
SELF_CHECK_TS("100us");
SELF_CHECK_TS("10us");
SELF_CHECK_TS("1us");
SELF_CHECK_TS("100ns");
SELF_CHECK_TS("10ns");
SELF_CHECK_TS("1ns");
SELF_CHECK_TS("100ps");
SELF_CHECK_TS("10ps");
SELF_CHECK_TS("1ps");
SELF_CHECK_TS("100fs");
SELF_CHECK_TS("10fs");
SELF_CHECK_TS("1fs");
SELF_CHECK_TS("100as");
SELF_CHECK_TS("10as");
SELF_CHECK_TS("1as");
}
#endif
#endif // VL_CPPCHECK

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