Compare commits

..
276 Commits
Author SHA1 Message Date
Wilson Snyder eca2b4c960 Version bump 2025-04-27 12:58:57 -04:00
Wilson Snyder c9be36911f Cleanup documentated option sort order, and enforce with test 2025-04-26 17:14:49 -04:00
Wilson Snyder c3d1c3b952 Fix vlSelf error on fork repeats (#5927). 2025-04-26 09:52:44 -04:00
Wilson Snyder e7adae6f81 Internals: Cleanup some vlSelf code. No functional change intended. 2025-04-26 09:51:02 -04:00
Wilson Snyder abc46db3c0 Tests: Cleanup some .cpp paths. No test functional change indended. 2025-04-25 20:57:11 -04:00
Wilson Snyder dd6cd3decb Commentary: Changes update 2025-04-25 20:55:18 -04:00
Wilson Snyder ebe49552b0 Fix packed selection using over 32-bit index (#5957). 2025-04-24 18:25:55 -04:00
Bartłomiej Chmiel d6e52b9400 Support profiling nested hierarchical mtasks with verilator_gantt (#5956) 2025-04-24 07:50:07 -04:00
Geza Lore 6ac2aa2d99 Add RTLMeter GitHub workflows (#5948)
Add the GitHub Actions workflows for running RTLMeter.

Runs start daily, at 02:00 UTC, on ubuntu-24.04. There are 2 runs:
- Using GCC, with default verilator options
- Using Clang, with "--threads 4"

Each run uses a maximum of 2 runners in parallel (so max 4 in total),
and takes slightly over 2 hours to complete.

The jobs will fail if a benchmark is broken, so this already serves as a
regression test for the included designs.

For now, performance metrics are recorded as artefacts of the run but
not otherwise published.

Performance metrics are always recorded for all successful jobs, even if
some cases are failing.
2025-04-19 15:42:33 +01:00
github action 7aad136972 Apply 'make format' 2025-04-18 09:36:29 +00:00
John Khoo fee839a80e Update UNOPTFLAT warning to suggest isolate_assignments (#5942) 2025-04-18 18:35:36 +09:00
Ryszard Rozak cbabd8abe1 Internals: Fix redundant edges in V3Trace (#5939). No functional change intended..
Signed-off-by: Ryszard Rozak <[email protected]>
2025-04-17 06:23:18 -04:00
Wilson Snyder 3ecd58460f Internals: Apply make format-json format-yaml. No functional change. 2025-04-16 07:34:57 -04:00
Wilson Snyder 09d27fa8a7 Commentary: Changes update 2025-04-16 07:34:04 -04:00
Yilou Wang e0fdb933a0 Support constraint random for StructArray (#5805) (#5937) 2025-04-16 07:08:46 -04:00
d0c4cc3938 Support user-defined primitives (UDPs) (#468) (#5807) (#5936)
Co-authored-by: Bartłomiej Chmiel <[email protected]>
Co-authored-by: Zhou Shen <[email protected]>
2025-04-16 06:32:18 -04:00
Ryszard Rozak 6a6a7b7e9f Fix stream expressions (#5938) 2025-04-15 11:50:43 -04:00
github action e3e8f18a4e Apply 'make format' 2025-04-15 01:41:13 +00:00
Brian Li 50d7f2afc6 Support assigning unpacked arrays to queues (#5924) (#5928) 2025-04-14 21:40:17 -04:00
Wilson Snyder 0359bf38e6 Commentary: Changes update 2025-04-12 18:10:55 -04:00
Wilson Snyder 174eafd74c Update libfst from upstream 2025-04-12 18:10:40 -04:00
Zhouyi Shen 3694d153ae Fix backward compatibility for TRACE option & Fix missing C++ regeneration when Verilog files are updated (#5934) 2025-04-12 17:49:41 -04:00
Andrew Voznytsa 9367e85c88 Add ccache support for generated cmake files (#5926) (#5930) 2025-04-12 16:02:31 -04:00
Wilson Snyder 7a2732f211 Fix parsing (no support) of covergroup functions 2025-04-12 13:07:38 -04:00
github action 999f251b3d Apply 'make format' 2025-04-12 11:36:25 +00:00
Robin Heinemann 10c3320c6b Support soft unions (#5912) (#5932) 2025-04-12 07:35:37 -04:00
Todd Strader 7336b9ebfc Add V3EmitV support for sampled value functions (#5931) 2025-04-11 12:25:56 -04:00
Bartłomiej Chmiel 84f26ed3d7 Add visualization of multi-threaded waiting time with verilator_gantt (#5929) 2025-04-10 10:03:58 -04:00
Wilson Snyder fc8e1b5a2e Fix several cmake issues, including TRACE_VCD 2025-04-10 07:49:58 -04:00
Ryszard Rozak 6bb57e4630 Fix assignments with stream expressions and unpacked arrays (#5915) 2025-04-09 06:37:52 -04:00
Wilson Snyder 2eb9076381 Revert 1ea9018e59 2025-04-09 00:00:22 -04:00
Wilson Snyder 1ea9018e59 Change JSON make format to have trace_fst/trace_saif/trace_vcd 2025-04-08 22:42:02 -04:00
Wilson Snyder a094fd954b Internals: Remove duplication in verilated.cpp file lists. No functional change intended. 2025-04-08 22:30:44 -04:00
Wilson Snyder 7c2b1971a4 Support class extends with arguments. 2025-04-08 22:09:40 -04:00
Wilson Snyder 86f6ac2960 Fix port default values with --coverage-line creating 0=0 (#5920). 2025-04-08 20:48:57 -04:00
Wilson Snyder f5312b83b9 Fix %% on elaboration severity tasks (#5922). 2025-04-07 08:38:05 -04:00
Wilson Snyder 0a3de7c74a Commentary: Changes update 2025-04-07 08:32:31 -04:00
Wilson Snyder b26a19279a Support simple checker blocks (#4066). 2025-04-06 23:42:49 -04:00
Wilson Snyder fcefa96397 Tests: Disable warning in t_gantt_numa. 2025-04-06 23:16:51 -04:00
Wilson Snyder c8a945f363 Internals: Minor refactoring of checker parsing/tests. No functional change. 2025-04-06 23:13:24 -04:00
Wilson Snyder c7ff82f06b Tests: Fix driver.py not stopping on interrupts (#5752) (#5921) 2025-04-06 19:03:39 -04:00
Wilson Snyder 6997a7c516 Fix format mis-indendenting t_assert_ctl_arg 2025-04-06 12:44:30 -04:00
Wilson Snyder eefbd94966 Fix format mis-indendenting t_assert_ctl_arg 2025-04-06 10:39:07 -04:00
Wilson Snyder d1a0bad334 Tests: Add test for (#4040). 2025-04-06 10:24:49 -04:00
github action 5cca1b101c Apply 'make format' 2025-04-06 01:19:33 +00:00
Wilson Snyder 18aeb080ad Fix empty test, part of last commit. 2025-04-05 21:14:27 -04:00
Wilson Snyder e9fe8f65a8 Change error messages to more often suggest documentation 2025-04-05 17:10:44 -04:00
github action eccfd8c6f9 Apply 'make format' 2025-04-05 19:37:32 +00:00
Wilson Snyder af03d91714 Tests: Fix truncated file 2025-04-05 15:36:24 -04:00
Wilson Snyder c3fd34b489 Tests: Add t_virtual_interface_delayed (#4322) 2025-04-05 15:31:17 -04:00
Wilson Snyder e12b971ba6 Optimize SAIF writes (#5916) 2025-04-05 15:09:32 -04:00
github action 2bbb24eb38 Apply 'make format' 2025-04-05 18:20:51 +00:00
Wilson Snyder 34a760b75b Optimize duplicate timestamps out of traces (#4686) 2025-04-05 14:19:58 -04:00
Wilson Snyder 7cc40d277b Tests: Cleanup some .out filenames. No test coverage change. 2025-04-05 13:46:22 -04:00
Wilson Snyder 0984fd045f Change --trace to --trace-vcd. 2025-04-05 10:46:39 -04:00
Wilson Snyder d5077a9d35 Commentary (#5919) 2025-04-05 09:45:07 -04:00
Yutetsu TAKATSUKASA b9f0612db8 Fix LATCH warning for automatic variables (#5918) 2025-04-05 06:21:34 -04:00
Wilson Snyder 6ba06498db Fix segfault in fork synchronization (#5906). 2025-04-04 08:15:39 -04:00
Wilson Snyder 73d52c00bb Tests: Note other simulator results 2025-04-04 07:44:04 -04:00
Wilson Snyder 87ee6c8746 Tests: Only != is globally allowed to compare strings 2025-04-03 21:26:53 -04:00
Mateusz Gancarz e4771dac7f In SAIF dumps include signals with TC 0 (#5914) 2025-04-03 16:25:10 -04:00
Wilson Snyder 14e7b1076e Commentary: Changes update 2025-04-02 23:17:39 -04:00
Wilson Snyder f55fee1cf0 Internals: Fix missing semis; no functional change 2025-04-02 23:13:43 -04:00
Ryszard Rozak 353a4b7b4a Fix parameters referencing interface fields (#1593) (#5910) 2025-04-02 09:43:12 -04:00
Wilson Snyder 6d1e82b908 Add numactl-like automatic assignment of processor affinity (#5911) 2025-04-02 08:27:23 -04:00
Krzysztof Sychla cd5997a2e6 Support $setuphold (#5884) 2025-04-02 06:08:51 -04:00
Wilson Snyder 0b9c2163d5 Tests: Cleanup some gantt tests; no test functional change 2025-04-01 22:54:39 -04:00
Wilson Snyder 168f0ed9e5 Fix new this (#5909). 2025-04-01 08:12:34 -04:00
Wilson Snyder 538f39edf9 Fix grammar. 2025-04-01 07:54:56 -04:00
github action e3c1d36e6e Apply 'make format' 2025-04-01 11:34:45 +00:00
Brian Li 559d990e82 Support command-line overriding `define (#5900) (#5908) 2025-04-01 07:33:49 -04:00
Wilson Snyder f3684a85b9 Fix delayed assignment malformed LHS assertion (#5904). 2025-03-30 17:38:54 -04:00
Wilson Snyder b49351356e Fix delays inside interface functions, and classes inside interfaces (#5846). 2025-03-30 16:40:22 -04:00
Wilson Snyder 21229e0350 Update libfst from upstream (gtkwave/libfst#12) 2025-03-30 11:10:38 -04:00
Wilson Snyder 6f87443da5 Commentary 2025-03-30 11:02:21 -04:00
Wilson Snyder 0a860f151c Cleanup some missed make clean files 2025-03-30 11:02:05 -04:00
Wilson Snyder 2116b424b9 Tests: Cleanup as --binary implies --timing. No test functional change. 2025-03-29 15:50:07 -04:00
Wilson Snyder e6a997e316 CI: Use reusable workflow, so tests start after build (#5901) 2025-03-29 15:09:32 -04:00
Wilson Snyder f29eeecee7 Fix process comparisons (#5896). 2025-03-29 07:16:54 -04:00
Wilson Snyder 2b8b1c4281 Tests: Disable running some lint tests on vltmt 2025-03-29 07:14:45 -04:00
Wilson Snyder 610b2e75af CI: Add vltmt-2 to bring longpath test time down 2025-03-29 06:54:30 -04:00
Wilson Snyder fd960b5f77 Commentary: Changes update 2025-03-28 23:14:15 -04:00
Wilson Snyder 9b48cc33db Fix process comparisons (#5896). 2025-03-28 22:40:21 -04:00
Wilson Snyder 844448655e Add `systemc_header_post 2025-03-28 22:40:21 -04:00
Wilson Snyder b4ef6ce860 Support systemc_interface and related inside class`. 2025-03-28 22:40:21 -04:00
Wilson Snyder 6edf2f80a2 Tests: Rename t_extend_c_class 2025-03-28 22:40:21 -04:00
Wilson Snyder 8e7f29b07e Fix incorrect systemc block token names 2025-03-28 22:40:21 -04:00
Geza Lore 28824b7597 Fix ccache with clang (#5899)
Lately ccache was mostly missing when using clang. Add '-Xclang
-fno-pch-timestamp' as recommended in the ccache manual.  This indeed
fixes the caching.
2025-03-28 18:25:53 +00:00
Geza Lore 39c3e79a3c Fix V3Gate assertion on eliminated circular logic (#5889) (#5898)
Fixes #5889
2025-03-28 17:04:09 +00:00
Geza Lore b6bcbd5660 Internals: Fix clang-tidy warnings in DFG (#5893) (#5897) 2025-03-28 12:06:13 -04:00
Wilson Snyder ed1e3ec4a2 Internals: Fix some clang-tidy issues. No functional change. 2025-03-27 21:21:37 -04:00
Wilson Snyder 98b89d0f2c Fix some cppcheck warnings. No functional change intended. 2025-03-27 19:46:59 -04:00
Wilson Snyder 5e69faff46 Fix clang 20 warnings 2025-03-27 19:01:25 -04:00
Wilson Snyder 40acac1c57 Fix queue accessing past end (Clang 20 GLIBC warning) 2025-03-27 19:00:43 -04:00
Wilson Snyder d26d62a176 Tests: Add driver.py --driver-clean 2025-03-27 18:33:18 -04:00
Bartłomiej Chmiel 8965401d10 Fix PGO profiling for multi-threaded hierarchical scenarios (#5888) 2025-03-27 11:10:48 -04:00
Luca Colagrande b9a571916c ci: Enable manual Docker image build and push (#5885) 2025-03-26 09:46:36 -04:00
Bartłomiej Chmiel cdab9479b8 Commentary: Fix bugpoint link (#5883)
Signed-off-by: Bartłomiej Chmiel <[email protected]>
2025-03-26 07:05:18 -04:00
Wilson Snyder ce058cc432 Fix $fscanf not returning -1 on EOF (#5881). 2025-03-25 08:28:36 -04:00
Wilson Snyder 4dd49e1244 Commentary: Changes update 2025-03-25 08:24:19 -04:00
Bartłomiej Chmiel fabded95df Support multi-thread hierarchical simulation (#2583) (#5871) 2025-03-24 18:39:29 -04:00
Wilson Snyder 7521c2c644 Standardize some error messages. 2025-03-23 19:51:54 -04:00
Wilson Snyder 464e19caaa Tests: Fix ubuntu24.04-arm issues 2025-03-22 16:55:53 -04:00
Wilson Snyder 0b6be2809e Tests: Fix bad ETA at startup 2025-03-22 08:49:40 -04:00
Wilson Snyder f9109eb61f Delay deletes in V3Fork (#5862 attempt) 2025-03-22 08:03:25 -04:00
Wilson Snyder 48effad448 Add DEPRECATED warning on --xml-only and --xml-output. 2025-03-21 21:32:05 -04:00
Wilson Snyder 29b439b93f Commentary 2025-03-21 17:43:07 -04:00
Nick Brereton 27e39d7821 Fix interface array assignments (#5270) (#5633) (#5869) 2025-03-21 17:00:49 -04:00
Todd Strader 8c287134d7 Add warning on expression coverage class references (#5870) 2025-03-21 08:55:38 -04:00
Wilson Snyder c508fd5d24 Internals: Remove single-statement braces. No functional change. 2025-03-19 22:55:11 -04:00
Wilson Snyder 62afbed3cd Commentary: Changes update 2025-03-19 19:06:44 -04:00
Todd Strader d2b7b567df Fix expression coverage on additional nodes (#5849 partial) (#5867) 2025-03-19 19:01:31 -04:00
Wilson Snyder 39bdd427d6 Fix unresolved typedefs as parameters (#5850). 2025-03-19 18:02:56 -04:00
Geza Lore 4a2212949e Fix change detection at time 0 (#5864)
Initialize "previous value" variables in the static initializer
function, instead of the 'initial' blocks function. Fixes #5499
2025-03-18 13:34:04 +00:00
Wilson Snyder 780163b91e Internals: Avoid extra op#() calls. No functional change intended. 2025-03-16 14:34:19 -04:00
Wilson Snyder 21eb43a554 Commentary: Changes update 2025-03-15 21:59:47 -04:00
Wilson Snyder 353ef5c436 Commentary 2025-03-15 21:57:31 -04:00
Wilson Snyder 77cc93c176 Fix detecting bad datatype on $countones (#5674). 2025-03-15 21:57:10 -04:00
Wilson Snyder 418fc2c246 Fix reduction-or on class pointers (prep #5674) 2025-03-15 21:46:37 -04:00
William D. Jones 13c22690c4 Fix algorithm header portability in V3Os.cpp (for std::replace). (#5861) 2025-03-15 21:43:06 -04:00
Tobias Jensen ae87df7a5d Fix Windows paths in perl (#5858) (#5860)
Add colon to no escape list, for windows paths
2025-03-15 14:22:10 -04:00
Geza Lore 59cb53cfbc Set trigger vector in whole words (#5857)
Having many triggers still hits a bottleneck in LLVM leading to long
compile times.

Instead of setting triggers bit-wise, set them as a whole 64-bit word
when possible. This improves C++ compile times by ~4x on some large
designs and has minor run-time performance benefit.
2025-03-14 14:06:51 +00:00
Geza Lore aca3b1636a Remove unused gtkwave/wavealloca.h 2025-03-13 14:43:35 +00:00
Ryszard Rozak 9a6598b36f Fix streaming of unpacked arrays concatenations (#5856) 2025-03-13 13:56:29 +01:00
Geza Lore 51a97ccb90 Update libfst from upstream (#5855)
Ignore whitespace if comparing this change.
2025-03-13 07:24:47 -04:00
Wilson Snyder 0aac3074b6 Fix recursive error on virtual interfaces (#5854). 2025-03-12 17:57:02 -04:00
Wilson Snyder 391d4e1c32 Fix segmentation fault on member compare (#5853). 2025-03-12 08:06:34 -04:00
Wilson Snyder 45add07205 Internals: Minor V3Param cleanups. No functional change. 2025-03-12 07:58:26 -04:00
Wilson Snyder 64caa700d3 Commentary: Changes update 2025-03-12 07:58:26 -04:00
github action a5eb9a5b9d Apply 'make format' 2025-03-11 23:58:06 +00:00
Andrew Voznytsa 6a48d3bb83 Add --make json to enable integration with non-make/cmake build systems (#5799) 2025-03-11 19:57:21 -04:00
Wilson Snyder 53151d7c5f Fix emitting this (#5849) 2025-03-11 17:53:35 -04:00
Wilson Snyder 78198d90e1 Commentary: Changes update 2025-03-11 17:49:19 -04:00
Wilson Snyder 9c044a9184 Commentary 2025-03-11 17:47:58 -04:00
github action f62b3faaf2 Apply 'make format' 2025-03-11 21:45:01 +00:00
Gilberto Abram 4dbb066b96 Fix removal of callbacks no longer in current list (#5851) (#5852) 2025-03-11 17:44:12 -04:00
Yilou Wang 7fe51583e5 Fix foreach of assocArr inside a constraint block (#5727) (#5841) 2025-03-11 13:32:34 -04:00
Geza Lore 6ecdd14fdb Fix NBA shared flag reuse (#5848)
Fixes #5847
2025-03-11 07:40:21 -04:00
Wilson Snyder 8157f21c3e Internals: Refactor hasGParam. No functional change intended. 2025-03-09 16:10:38 -04:00
Wilson Snyder 781bd3cc09 Commentary: Changes update 2025-03-09 13:15:53 -04:00
Wilson Snyder a2e91f3cf2 Internals: Add some const. No functional change. 2025-03-09 13:13:57 -04:00
Geza Lore d9701e6406 Automatically split some packed variables (#5843)
This patch adds a heuristic to V3SplitVar, and it attempts to split up
packed variables that are only referenced via constant index,
non-overlapping bit/range selects. This can eliminate some UNOPTFLAT cases.
2025-03-09 10:31:01 -04:00
Wilson Snyder 128231b077 Tests: Parameter pattern init (#3144) 2025-03-08 19:13:20 -05:00
Wilson Snyder ce2f335786 Internals: Set isParameterized near hasGParam. No functional change intended. 2025-03-08 17:53:24 -05:00
Wilson Snyder 9632dfdf93 Internals: Remove some unneeded this->. No functional change. 2025-03-08 17:48:20 -05:00
Wilson Snyder 8026b2a7f3 Fix checking built-in method arguments (#5839) 2025-03-08 14:11:12 -05:00
Wilson Snyder 24dbb0bc5c Internals: V3Width call refactoring. No functional change. 2025-03-08 12:44:30 -05:00
github action 5045bf53df Apply 'make format' 2025-03-08 16:09:07 +00:00
Wilson Snyder 51fcb881d5 Fix error on out-of-range lvalue part select (#5820). 2025-03-08 11:05:58 -05:00
Geza Lore 20b964a9a2 Fix splitting of packed ports with non-zero based ranges (#5842) 2025-03-08 09:37:30 -05:00
Wilson Snyder 10a77a17a9 Commentary (#5840) 2025-03-07 23:31:34 -05:00
Wilson Snyder a62f7fe4ae Commentary: Changes update 2025-03-07 18:03:01 -05:00
Mateusz Gancarz 9b4509f7d9 Add --trace-saif for SAIF power traces (#5812) 2025-03-07 10:41:29 -05:00
Geza Lore 96bffd49aa Fix invalidating variable caches in SenExprBulider (#5834) (#5835) 2025-03-07 07:18:34 -05:00
Krzysztof Bieganski b2093b513a Fix type_id package scope resolution (#5826) 2025-03-06 17:41:27 -05:00
Wilson Snyder 8e87a99628 Fix rand_mode method with cast (#5831). 2025-03-05 21:43:50 -05:00
Wilson Snyder 258becd179 Add empty veriuser.h for legacy compatibility. 2025-03-04 21:25:28 -05:00
Geza Lore 2cad858d32 Bump vcddiff (#5828)
For #5806 via veripool/vcddiff#5
2025-03-04 16:21:25 +00:00
Bartłomiej Chmiel a3b2c2af17 Support force/release with a variable reference (#5721) (#5810) 2025-03-04 10:12:02 -05:00
Wilson Snyder 27d3eb5b7b Fix UNOPTFLAT warnings with --coverage-trace and always_comb (#5821). 2025-03-02 20:02:55 -05:00
Wilson Snyder ce211ebceb Internals: Make some auto more explicit. No functional change. 2025-03-02 17:01:35 -05:00
Wilson Snyder 4bf8f47f59 Commentary: Changes update 2025-03-02 17:01:06 -05:00
Wilson Snyder b54f897090 Tests: Fix Ubuntu24.04 clang test issues, and enable action (#5824) 2025-03-02 16:53:59 -05:00
Wilson Snyder d31bce915c Actions: Turn off Ubuntu 20.04 (#5774) (#5823) 2025-03-02 12:33:36 -05:00
Geza Lore 0133bc6b09 Do not use function locals in SenExprBuilder (#5822)
Function locals are not safe here because we might need to split up
the generated function. V3Localize can fix them later if safe.
2025-03-02 16:13:59 +00:00
Geza Lore bab949a468 Use tcmalloc on non 22.04 CI builds (#5818) 2025-03-02 08:13:20 +00:00
Geza Lore 99064d3e39 Make mold static link tcmalloc (#5817) 2025-03-02 00:20:16 +00:00
Geza Lore fc302a5207 Fix sorting of wide SenItems (#5816)
This used to throw Error: Value too wide for 64-bits expected in this context
2025-03-01 22:11:43 +00:00
Geza Lore 14f618b0f6 Fix invalid code motion over branches (#5811) (#5814) 2025-02-28 13:32:03 -05:00
Wilson Snyder a9762e0c5c Fix coredump on fork inside disable named block by adding an UNSUPPORTED 2025-02-27 21:42:20 -05:00
Wilson Snyder 098ee6fa7a Internals: Cleanup some missing VL_RESTORERs. No functional change intended. 2025-02-27 21:18:27 -05:00
Wilson Snyder 7f94fa1da7 Add check for let misused in statement context (#5733). 2025-02-26 09:08:41 -05:00
Wilson Snyder 3b98db17cc Fix reset of automatic function variables (#5747).
Also required V3Life optimize CRESET(x) ... ASSIGN(rhs, x) to remove the
extraneous CRESET to avoid creating new UNOPTFLAT situations.
2025-02-25 22:48:53 -05:00
Wilson Snyder 233b6eafba Commentary: Changes update 2025-02-25 22:44:55 -05:00
Wilson Snyder 489349ffbd Internals: Reduce verbosity of SplitVar 2025-02-25 20:41:00 -05:00
Wilson Snyder b52e1d3ede Fix wrong fileline on 1step 2025-02-25 20:40:33 -05:00
Bartłomiej Chmiel 6a8f97e184 Internals: Fix typos (#5803)
Signed-off-by: Bartłomiej Chmiel <[email protected]>
2025-02-25 12:44:14 -05:00
Kamil Rakoczy 3ab89d5be7 Add used language to --preproc-resolve output (#5795) 2025-02-25 07:03:25 -05:00
Wilson Snyder b35ab0b843 Tests: Fix last commit 2025-02-24 22:39:30 -05:00
Wilson Snyder 6c46c4f6f7 Tests: Add unsupported test for specparam (#5767). 2025-02-24 21:01:05 -05:00
Wilson Snyder 2455d15271 Change --output-groups to default to value of --build-jobs.
Those using build farms may need to now use `--output-groups 0` or otherwise.
2025-02-24 20:39:27 -05:00
Wilson Snyder d232923051 Change --output-groups to default to value of --build-jobs.
Those using build farms may need to now use `--output-groups 0` or otherwise.
2025-02-24 20:38:08 -05:00
Wilson Snyder e6678f6546 devel release 2025-02-24 18:33:43 -05:00
Wilson Snyder 436d3d76f0 Version bump 2025-02-24 18:19:40 -05:00
Wilson Snyder c1f0787669 Commentary: Changes update 2025-02-24 18:15:08 -05:00
Yilou Wang dae4c8ee22 Support constrained random for arrays in structs (#5765) (#5802) 2025-02-24 17:51:51 -05:00
Wilson Snyder 5daf7385f1 Commentary: Changes update 2025-02-24 04:04:23 -05:00
Wilson Snyder 4ce8164277 Fix parsing input wire with default and range (#5800). 2025-02-24 03:51:49 -05:00
Todd Strader 7ec32799b0 Fix expression coverage + VarXRefs (#5797) 2025-02-22 15:55:23 -05:00
Geza Lore 812861e7f2 Optimize splitting trigger computation and dump (#5798) 2025-02-23 05:57:36 +10:00
Wilson Snyder 1857f6399c Fix $monitor with dotted references (#5794). 2025-02-21 17:18:49 -05:00
Todd Strader f7ccc013e7 Improve V3EmitV for interfaces (#5796) 2025-02-21 16:49:14 -05:00
Kamil Rakoczy 2e1fa8f338 Add --preproc-resolve for modules in preprocessor output (#5789)
Signed-off-by: Kamil Rakoczy <[email protected]>
2025-02-22 04:47:54 +10:00
Todd Strader 70459b3208 Fix V3EmitV for non-zero based arrays (#5790) 2025-02-21 05:49:32 +11:00
Ryszard Rozak 2a23ec74e4 Fix dpi context functions (#5788) 2025-02-20 10:15:09 +01:00
Wilson Snyder be1ace423e Fix time import error on time parameters (#5786). 2025-02-19 17:03:59 -05:00
Wilson Snyder 2d0149b703 Commentary: Changes update 2025-02-19 17:00:29 -05:00
Todd Strader 34ced254c0 Support expression coverage (#5719) 2025-02-19 16:42:23 -05:00
Wilson Snyder fe15171649 Internals: cppcheck cleanups. No functional change. 2025-02-18 01:14:51 -05:00
Wilson Snyder 4092ac7e72 Commentary: Changes update 2025-02-18 01:05:10 -05:00
Yutetsu TAKATSUKASA 1a07af57a3 Fix unpacked split_var (#5782) (#5785) 2025-02-18 05:34:57 +11:00
Kamil Rakoczy c840ffb0ae Support nested classes (#4178) (#5778)
Signed-off-by: Kamil Rakoczy <[email protected]>
2025-02-17 23:47:41 +11:00
Wilson Snyder fbe8439eb8 Commentary: Changes update 2025-02-15 00:58:14 -05:00
Wilson Snyder 754c5c71f1 Fix force VPI public signal visibility (#5225). 2025-02-15 00:58:14 -05:00
Wilson Snyder 6940ee420d Commentary 2025-02-15 00:58:14 -05:00
Todd Strader b645fcf027 More V3EmitV support (#5779) 2025-02-14 14:58:11 -05:00
Krzysztof Bieganski ffb02cea15 Fix ignoring joins in stringify in preprocessor (#5777)
Signed-off-by: Krzysztof Bieganski <[email protected]>
2025-02-13 18:33:12 -05:00
Krzysztof Bieganski f753ae2518 Support selects on arbitrary string expressions (#5773) 2025-02-11 12:06:34 -05:00
Dave Sargeant caa19c0cb3 Fix VFileContent reference count (#5769) (#5771) 2025-02-10 10:04:04 -05:00
Trung Nguyen aa3942ab24 Internals: constexpr for VlUnpacked data access (#5725) (#5770)
Add `constexpr` to data access functions of `VlUnpacked` whose `std::array` equivalent in C++14 is `constexpr`.
2025-02-09 22:45:50 -05:00
github action cc1133c0d9 Apply 'make format' 2025-02-08 00:07:38 +00:00
Moubarak Jeje ac659d525b Support VPI array accessors (#5612) 2025-02-07 19:06:46 -05:00
Krzysztof Bieganski 283f6c7433 Add --preproc-token-limit (#5768) 2025-02-07 10:32:12 -05:00
Moubarak Jeje 5b65c15eca Internals: Add datap cast functions (#5761) 2025-02-05 15:29:54 -05:00
Yilou Wang 6b4183632c Support Unpacked Structures' Constrained Randomization (#5657) (#5759) 2025-02-03 11:56:00 -05:00
Wilson Snyder e0e164cea2 Internals: Optimize clearFired (#5753) 2025-01-30 07:52:38 -05:00
Bartłomiej Chmiel a379382d32 Fix handling forced assigns in V3Life (#5757) 2025-01-28 07:30:40 -05:00
Wilson Snyder e2a6e19cac Cleanup V3EmitMk report style 2025-01-25 17:52:27 -05:00
Wilson Snyder 61bfb6c308 Remove list/map from keyword warnings.
Reduces warning verbosity from `map` in UVM.
Assumes user doesn't do a `using namespace std`.
2025-01-25 16:08:15 -05:00
Wilson Snyder bdcfc4e286 Reduce verbosity under --debug default level 2025-01-25 16:01:20 -05:00
Wilson Snyder 70c6651aac Fix -Wno-subobject-linkage on GCC (#5754) 2025-01-25 15:45:30 -05:00
Wilson Snyder 41bb54bc2c Add Makefile targets count to stats 2025-01-25 13:35:56 -05:00
Wilson Snyder 001c098e5a Optimize empty function definition bodies (#5750). 2025-01-25 12:13:25 -05:00
Wilson Snyder 98e40c847c Internals: Suppress vlSelf unused suppression when known used. No functional change intended. 2025-01-25 12:06:05 -05:00
Wilson Snyder 05c7a3b90b Optimize labels as final if block statements (#5744). 2025-01-25 10:29:35 -05:00
Wilson Snyder 694f2ff7c7 Tests: renames 2025-01-25 10:24:59 -05:00
Wilson Snyder 6281385ee8 Commentary/Internals: Sort option names. No functional change. 2025-01-24 21:31:57 -05:00
Wilson Snyder 7e6dd9473f Commentary: Changes update 2025-01-24 21:27:52 -05:00
Wilson Snyder 929e15fa4c Fix various round-trip Verilog output, including packed arrays 2025-01-24 21:00:45 -05:00
Wilson Snyder 432d5f851d Internals: Cleanup some misnamed nodep's. No functional change. 2025-01-24 20:52:31 -05:00
Wilson Snyder d4f4fefd1d Fix -j ignored after -f (#5749). 2025-01-24 17:30:59 -05:00
Wilson Snyder d8080008b4 Commentary 2025-01-24 07:47:32 -05:00
Wilson Snyder bed9aa9904 Internals: Cleanup std::string empty string constructors. 2025-01-24 07:47:32 -05:00
Bartłomiej Chmiel 35fa0d051d Support integer atom type ports in --hierarchical (#5748) 2025-01-24 07:47:11 -05:00
Bartłomiej Chmiel 0507fb4655 Improve hierarchical DPI wrapper scheduling performance (#2583) (#5734) 2025-01-20 14:24:09 -05:00
Geza Lore f4a01eb452 Fix inlined expression with assignment under LHS of NBA (#5736) (#5740) 2025-01-20 07:23:10 -05:00
Wilson Snyder 4954e76b28 Commentary: Changes update 2025-01-18 15:26:41 -05:00
Wilson Snyder fa1b11252e Fix duplicate-named class variable equivalence (#5737). 2025-01-18 15:25:49 -05:00
Andrew Nolte dddc1b5b4d Fix vpiDefName issues with non-inlined scopes and dpi conflicts (#5732) 2025-01-16 15:02:36 -05:00
Natan Kreimer 20faa99464 Fix VPI iteration over hierarchy (#5314) (#5731) 2025-01-13 07:40:34 -05:00
Ethan Sifferman dc43071f1c Improve `resetall support (#5728) (#5730) 2025-01-11 22:53:11 -05:00
Wilson Snyder fdf29b970f Fix VL_UNLIKELY with constructors 2025-01-11 15:27:11 -05:00
Wilson Snyder 70814fa11a Commentary: Add --public-ignore to ignore public metacomments (#5716). 2025-01-11 12:34:12 -05:00
Wilson Snyder 529b8337ec Commentary: Changes update 2025-01-11 12:30:07 -05:00
Andrew Nolte f8dd65c7cd Add --public-ignore to ignore public metacomments (#7819) 2025-01-11 12:29:39 -05:00
Wilson Snyder 28a59a2b21 Update gtkwave from upstream. 2025-01-11 12:16:46 -05:00
Yilou Wang d3e205f201 Support constraints on associative array user-defined keys (#5671) (#5729) 2025-01-11 12:07:52 -05:00
Wilson Snyder dfe28f7ed0 Fix misoptimizing away $urandom (#5703). 2025-01-11 08:48:40 -05:00
github action bb871728c9 Apply 'make format' 2025-01-10 00:05:16 +00:00
Krzysztof Starecki 69dce205d3 Support multidimensional array access via VPI (#2812) (#5573) 2025-01-09 19:04:26 -05:00
Krzysztof Bieganski 052812bb87 Fix BLKSEQ on suspendable processes (#5722)
Signed-off-by: Krzysztof Bieganski <[email protected]>
2025-01-09 08:40:32 -05:00
Yilou Wang 0380a36c76 Fix constrained random for > 64-bit associative arrays (#5670) (#5682) 2025-01-09 08:33:38 -05:00
Wilson Snyder 44f49669a3 Support side effects of form variable[index_function()]++. 2025-01-08 19:37:20 -05:00
github action ff244c1d1f Apply 'make format' 2025-01-08 14:44:48 +00:00
Krzysztof Starecki 260ac342f4 Tests: Add support for Questa in TestSimulator class (#5718) 2025-01-08 09:43:57 -05:00
Nick Brereton 87d856339f Add lint error on importing package within a class (#5634) (#5679) 2025-01-07 16:52:44 -05:00
Wilson Snyder e171463fa2 Add COVERIGN warning, as a more specific UNSUPPORTED error. 2025-01-06 18:48:32 -05:00
Wilson Snyder 481adf8fe7 Commentary 2025-01-06 17:56:50 -05:00
Andrew Nolte b8288b97f7 Improve VPI write errors (#5712) 2025-01-06 17:56:18 -05:00
Andrew Nolte 0d34f56b74 Fix packages with --public-depth 1 (#5708) 2025-01-06 15:21:32 -05:00
Wilson Snyder dcaf6476e8 Fix matching language extension options including dots. 2025-01-05 22:52:29 -05:00
Wilson Snyder 76b2ac9cc1 Support +incdir with multiple directories. 2025-01-05 19:30:39 -05:00
Wilson Snyder b6a400ee9b Support generated classes (#5665). 2025-01-05 17:10:04 -05:00
Wilson Snyder 78d6ec8114 Fix error message when call task as a function (#3089). 2025-01-04 12:55:15 -05:00
Wilson Snyder 88dd95980a Internal cleanups, remove extra iterate, but no functional change intended 2025-01-04 12:50:55 -05:00
Wilson Snyder b531001f55 Fix segfault when only enum value referenced in package (#5714). 2025-01-04 10:36:34 -05:00
Wilson Snyder 1d0563212e Fix pattern assignment to real inside struct (#5713). 2025-01-03 19:39:48 -05:00
Wilson Snyder 8ca49d98c1 Fix %p format output for real inside struct (#5713). 2025-01-03 19:15:03 -05:00
Wilson Snyder 036c1fb0f9 Commentary: Changes update 2025-01-03 10:02:48 -05:00
Wilson Snyder 19258ee18a Commentary 2025-01-03 10:00:56 -05:00
أحمد المحمودي 578d8d8391 Fix man pages whatis section (#5710) 2025-01-03 09:58:33 -05:00
Geza Lore 010ae580b1 Fix V3Simulate constant reuse (#5709)
Use a generational allocator for reusing AstConst across
V3Simulate::clear(), instead of using user1 (which is also used
to store values of nodes).

Also fix invalid lookup on array initializer
2025-01-03 05:33:29 -05:00
Wilson Snyder 951f5eaa82 Commentary 2025-01-02 08:09:02 -05:00
Wilson Snyder 3a69dd4a43 Commentary 2025-01-02 08:07:57 -05:00
Wilson Snyder f52155a768 Copyright year update. 2025-01-02 06:21:30 -05:00
Wilson Snyder 16b3d9101c devel release 2025-01-01 09:11:15 -05:00
1339 changed files with 1127409 additions and 21216 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ assignees: ''
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.)
Can you attach an example that shows the issue? (Must be openly licensed, completely self-contained and self-checking so can directly run what you provide. Ideally use test_regress format, see https://veripool.org/guide/latest/contributing.html?highlight=test_regress#reporting-bugs
What 'verilator' command line do we use to run your example?
+1 -1
View File
@@ -13,6 +13,6 @@ What would you like added/supported?
What 'verilator --version' are you using? Did you try it with the git master version?
Can you attach an example that runs on other simulators? (Must be openly licensed, ideally in test_regress format.)
Can you attach an example that runs on other simulators? (Must be openly licensed, completely self-contained and self-checking so can directly run what you provide. Ideally use test_regress format, see https://veripool.org/guide/latest/contributing.html?highlight=test_regress#reporting-bugs
May we assist you in trying to fix this in Verilator yourself?
+128 -116
View File
@@ -12,15 +12,6 @@ on:
schedule:
- cron: '0 0 * * 0' # weekly
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95
INSTALL_DIR: ${{ github.workspace }}/install
RELOC_DIR: ${{ github.workspace }}/relloc
defaults:
run:
shell: bash
@@ -32,134 +23,155 @@ concurrency:
jobs:
build:
build-2404-gcc:
name: Build
uses: ./.github/workflows/reusable-build.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
compiler:
- {cc: clang, cxx: clang++}
- {cc: gcc, cxx: g++}
include:
# Build GCC 10 on ubuntu-20.04
- os: ubuntu-20.04
compiler: {cc: gcc-10, cxx: g++-10}
runs-on: ${{ matrix.os }}
name: Build | ${{ matrix.os }} | ${{ matrix.compiler.cc }}
env:
CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ${{ matrix.os }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: build-${{ matrix.os }}-${{ matrix.compiler.cc }}
CCACHE_MAXSIZE: 1000M # Per build matrix entry (* 5 = 5000M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
steps:
- {os: ubuntu-24.04, cc: gcc}
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Cache $CCACHE_DIR
uses: actions/cache@v4
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
- name: Install packages for build
run: ./ci/ci-install.bash
- name: Build
run: ./ci/ci-script.bash
- name: Tar up repository
working-directory: ${{ github.workspace }}
run: tar --posix -c -z -f ${{ env.VERILATOR_ARCHIVE }} repo
- name: Upload tar archive
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }}
name: ${{ env.VERILATOR_ARCHIVE }}
test:
needs: build
build-2404-clang:
name: Build
uses: ./.github/workflows/reusable-build.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
compiler:
- {cc: clang, cxx: clang++}
- {cc: gcc, cxx: g++}
reloc: [0]
suite: [dist-vlt-0, dist-vlt-1, dist-vlt-2, dist-vlt-3, vltmt-0, vltmt-1]
include:
# Test with GCC 10 on ubuntu-20.04, also test relocation
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: dist-vlt-0}
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: dist-vlt-1}
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: dist-vlt-2}
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: dist-vlt-3}
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: vltmt-0}
- {os: ubuntu-20.04, compiler: {cc: gcc-10, cxx: g++-10}, reloc: 1, suite: vltmt-1}
# Ubuntu 24.04 only on GCC; not passing on clang yet
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: dist-vlt-0}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: dist-vlt-1}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: dist-vlt-2}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: dist-vlt-3}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: vltmt-0}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, suite: vltmt-1}
runs-on: ${{ matrix.os }}
name: Test | ${{ matrix.os }} | ${{ matrix.compiler.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }}
env:
CI_BUILD_STAGE_NAME: test
CI_RUNS_ON: ${{ matrix.os }}
CI_RELOC: ${{ matrix.reloc }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
CACHE_BASE_KEY: test-${{ matrix.os }}-${{ matrix.compiler.cc }}-${{ matrix.reloc }}-${{ matrix.suite }}
CCACHE_MAXSIZE: 100M # Per build per suite (* 5 * 5 = 2500M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ matrix.os }}-${{ matrix.compiler.cc }}.tar.gz
steps:
- {os: ubuntu-24.04, cc: clang}
- name: Download tar archive
uses: actions/download-artifact@v4
with:
name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ github.workspace }}
build-2204-gcc:
name: Build
uses: ./.github/workflows/reusable-build.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-22.04, cc: gcc}
- name: Unpack tar archive
working-directory: ${{ github.workspace }}
run: tar -x -z -f ${{ env.VERILATOR_ARCHIVE }}
build-2204-clang:
name: Build
uses: ./.github/workflows/reusable-build.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-22.04, cc: clang}
- name: Cache $CCACHE_DIR
uses: actions/cache@v4
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
test-2404-gcc:
name: Test | ${{ matrix.os }} | ${{ matrix.cc }}
needs: build-2404-gcc
uses: ./.github/workflows/reusable-test.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
reloc: ${{ matrix.reloc }}
suite: ${{ matrix.suite }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu 24.04 gcc
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: dist-vlt-0}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: dist-vlt-1}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: dist-vlt-2}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: dist-vlt-3}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: vltmt-0}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: vltmt-1}
- {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: vltmt-2}
- name: Install test dependencies
run: ./ci/ci-install.bash
test-2404-clang:
name: Test | ${{ matrix.os }} | ${{ matrix.cc }}
needs: build-2404-clang
uses: ./.github/workflows/reusable-test.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
reloc: ${{ matrix.reloc }}
suite: ${{ matrix.suite }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu 24.04 clang
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: dist-vlt-0}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: dist-vlt-1}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: dist-vlt-2}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: dist-vlt-3}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: vltmt-0}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: vltmt-1}
- {os: ubuntu-24.04, cc: clang, reloc: 0, suite: vltmt-2}
- name: Test
env:
TESTS: ${{ matrix.suite }}
run: ./ci/ci-script.bash
test-2204-gcc:
name: Test | ${{ matrix.os }} | ${{ matrix.cc }}
needs: build-2204-gcc
uses: ./.github/workflows/reusable-test.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
reloc: ${{ matrix.reloc }}
suite: ${{ matrix.suite }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu 22.04 gcc
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: dist-vlt-0}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: dist-vlt-1}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: dist-vlt-2}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: dist-vlt-3}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: vltmt-0}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: vltmt-1}
- {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: vltmt-2}
test-2204-clang:
name: Test | ${{ matrix.os }} | ${{ matrix.cc }}
needs: build-2204-clang
uses: ./.github/workflows/reusable-test.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
reloc: ${{ matrix.reloc }}
suite: ${{ matrix.suite }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu 22.04 clang, also test relocation
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: dist-vlt-0}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: dist-vlt-1}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: dist-vlt-2}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: dist-vlt-3}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: vltmt-0}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: vltmt-1}
- {os: ubuntu-22.04, cc: clang, reloc: 1, suite: vltmt-2}
lint-py:
runs-on: ubuntu-22.04
name: Lint Python
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ubuntu-22.04
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
+2 -2
View File
@@ -76,11 +76,11 @@ jobs:
- name: Build and Push to Docker
uses: docker/build-push-action@v4
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
with:
context: ${{ env.build_context }}
build-args: SOURCE_COMMIT=${{ env.git_tag }}
platforms: linux/arm64,linux/amd64
push: ${{ !env.ACT && startsWith(github.ref, 'refs/tags/v') }}
push: ${{ !env.ACT && (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
+76
View File
@@ -0,0 +1,76 @@
---
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: reusable-build
on:
workflow_call:
inputs:
os: # e.g. ubuntu-24.04
required: true
type: string
cc: # gcc or clang
required: true
type: string
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95
INSTALL_DIR: ${{ github.workspace }}/install
RELOC_DIR: ${{ github.workspace }}/relloc
defaults:
run:
shell: bash
working-directory: repo
jobs:
build:
runs-on: ${{ inputs.os }}
name: Sub-build | ${{ inputs.os }} | ${{ inputs.cc }}
env:
CI_BUILD_STAGE_NAME: build
CI_RUNS_ON: ${{ inputs.os }}
CC: ${{ inputs.cc }}
CXX: ${{ inputs.cc == 'clang' && 'clang++' || 'g++' }}
CACHE_BASE_KEY: build-${{ inputs.os }}-${{ inputs.cc }}
CCACHE_MAXSIZE: 1000M # Per build matrix entry (* 5 = 5000M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ inputs.os }}-${{ inputs.cc }}.tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Cache $CCACHE_DIR
uses: actions/cache@v4
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
- name: Install packages for build
run: ./ci/ci-install.bash
- name: Build
run: ./ci/ci-script.bash
- name: Tar up repository
working-directory: ${{ github.workspace }}
run: tar --posix -c -z -f ${{ env.VERILATOR_ARCHIVE }} repo
- name: Upload tar archive
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/${{ env.VERILATOR_ARCHIVE }}
name: ${{ env.VERILATOR_ARCHIVE }}
@@ -0,0 +1,73 @@
---
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: reusable-rtlmeter-build
on:
workflow_call:
inputs:
runs-on:
description: "Runner to use, e.g.: ubuntu-24.04"
type: string
required: true
cc:
description: "Compiler to use: 'gcc' or 'clang'"
type: string
required: true
defaults:
run:
shell: bash
env:
CCACHE_DIR: ${{ github.workspace }}/ccache
CCACHE_MAXSIZE: 512M
jobs:
build:
runs-on: ${{ inputs.runs-on }}
name: Build
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install ccache mold help2man libfl-dev libgoogle-perftools-dev libsystemc-dev
- name: Use saved ccache
uses: actions/cache@v4
with:
path: ccache
key: rtlmeter-build-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: rtlmeter-build-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
fetch-depth: 0 # Required for 'git describe' used for 'verilator --version'
- name: Configure
working-directory: repo
run: |
autoconf
./configure --prefix=${{ github.workspace }}/install CXX=${{ inputs.cc == 'clang' && 'clang++' || 'g++' }}
- name: Make
working-directory: repo
run: make -j $(nproc)
- name: Install
working-directory: repo
run: make install
- name: Tar up installation
run: tar --posix -c -z -f verilator-rtlmeter.tar.gz install
- name: Upload Verilator installation archive
uses: actions/upload-artifact@v4
with:
path: verilator-rtlmeter.tar.gz
name: verilator-rtlmeter-${{ inputs.runs-on }}-${{ inputs.cc }}
overwrite: true
+118
View File
@@ -0,0 +1,118 @@
---
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: reusable-rtlmeter-run
on:
workflow_call:
inputs:
runs-on:
description: "Runner to use, e.g.: ubuntu-24.04"
type: string
required: true
cc:
description: "Compiler to use: 'gcc' or 'clang'"
type: string
required: true
cases:
description: "RTLMeter cases to run"
type: string
required: true
compileArgs:
description: "Additional Verilator command line arguments"
type: string
default: ""
executeArgs:
description: "Additional simulator command line arguments"
type: string
default: ""
defaults:
run:
shell: bash
env:
CCACHE_DIR: ${{ github.workspace }}/ccache
CCACHE_MAXSIZE: 512M
CCACHE_DISABLE: 1
jobs:
run:
runs-on: ${{ inputs.runs-on }}
name: Run
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install ccache mold libfl-dev libgoogle-perftools-dev libsystemc-dev
- name: Download Verilator installation archive
uses: actions/download-artifact@v4
with:
name: verilator-rtlmeter-${{ inputs.runs-on }}-${{ inputs.cc }}
- name: Unpack Verilator installation archive
run: |
tar -x -z -f verilator-rtlmeter.tar.gz
echo "${{ github.workspace }}/install/bin" >> $GITHUB_PATH
- name: Use saved ccache
if: ${{ env.CCACHE_DISABLE == 0 }}
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: rtlmeter-run-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.cases }}-${{ inputs.compileArgs }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: rtlmeter-run-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.cases }}-${{ inputs.compileArgs }}
- name: Checkout RTLMeter
uses: actions/checkout@v4
with:
repository: "verilator/rtlmeter"
path: rtlmeter
- name: Setup RTLMeter venv
working-directory: rtlmeter
run: make venv
- name: Compile cases
working-directory: rtlmeter
run: |
./rtlmeter run --verbose --cases='${{ inputs.cases }}' --compileArgs='${{ inputs.compileArgs }}' --executeArgs='${{ inputs.executeArgs }}' --nExecute=0
# My YAML highlighter sucks, so I put this comment here wiht a phony closing quote mark to make it work: '
- name: Execute cases
working-directory: rtlmeter
continue-on-error: true # Do not fail on error, so we can at leat save the successful results
run: |
./rtlmeter run --verbose --cases='${{ inputs.cases }}' --compileArgs='${{ inputs.compileArgs }}' --executeArgs='${{ inputs.executeArgs }}'
# My YAML highlighter sucks, so I put this comment here wiht a phony closing quote mark to make it work: '
- name: Collate results
id: results
working-directory: rtlmeter
run: |
# 'inputs.cases' has special characters, use its md5sum as unique id
hash=$(md5sum <<< '${{ inputs.cases }}' | awk '{print $1}')
echo "hash=${hash}" >> $GITHUB_OUTPUT
./rtlmeter collate > ../results-${hash}.json
- name: Report results
working-directory: rtlmeter
run: |
./rtlmeter report --steps '*' --metrics '*' ../results-${{ steps.results.outputs.hash }}.json
- name: Upload results
uses: actions/upload-artifact@v4
with:
path: results-${{ steps.results.outputs.hash }}.json
name: rtlmeter-results-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ steps.results.outputs.hash }}
overwrite: true
retention-days: 2
- name: Report status
working-directory: rtlmeter
run: | # This will fail the job if any of the runs failed
./rtlmeter run --verbose --cases='${{ inputs.cases }}' --compileArgs='${{ inputs.compileArgs }}' --executeArgs='${{ inputs.executeArgs }}'
# My YAML highlighter sucks, so I put this comment here wiht a phony closing quote mark to make it work: '
+80
View File
@@ -0,0 +1,80 @@
---
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: reusable-build
on:
workflow_call:
inputs:
os: # e.g. ubuntu-24.04
required: true
type: string
cc: # gcc or clang
required: true
type: string
reloc: # 0 or 1
required: true
type: number
suite: # e.g. dist-vlt-0
required: true
type: string
env:
CI_OS_NAME: linux
CI_COMMIT: ${{ github.sha }}
CCACHE_COMPRESS: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_LIMIT_MULTIPLE: 0.95
INSTALL_DIR: ${{ github.workspace }}/install
RELOC_DIR: ${{ github.workspace }}/relloc
defaults:
run:
shell: bash
working-directory: repo
jobs:
test:
runs-on: ${{ inputs.os }}
name: Sub-test | ${{ inputs.os }} | ${{ inputs.cc }} | ${{inputs.reloc && 'reloc | ' || '' }} ${{ inputs.suite }}
env:
CI_BUILD_STAGE_NAME: test
CI_RUNS_ON: ${{ inputs.os }}
CI_RELOC: ${{inputs.reloc }}
CC: ${{ inputs.cc }}
CXX: ${{ inputs.cc == 'clang' && 'clang++' || 'g++' }}
CACHE_BASE_KEY: test-${{ inputs.os }}-${{ inputs.cc }}-${{inputs.reloc }}-${{ inputs.suite }}
CCACHE_MAXSIZE: 100M # Per build per suite (* 5 * 5 = 2500M in total)
VERILATOR_ARCHIVE: verilator-${{ github.sha }}-${{ inputs.os }}-${{ inputs.cc }}.tar.gz
steps:
- name: Download tar archive
uses: actions/download-artifact@v4
with:
name: ${{ env.VERILATOR_ARCHIVE }}
path: ${{ github.workspace }}
- name: Unpack tar archive
working-directory: ${{ github.workspace }}
run: tar -x -z -f ${{ env.VERILATOR_ARCHIVE }}
- name: Cache $CCACHE_DIR
uses: actions/cache@v4
env:
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
restore-keys: |
${{ env.CACHE_KEY }}-
- name: Install test dependencies
run: ./ci/ci-install.bash
- name: Test
env:
TESTS: ${{ inputs.suite }}
run: ./ci/ci-script.bash
+158
View File
@@ -0,0 +1,158 @@
---
# DESCRIPTION: Github actions config
# This name is key to badges in README.rst, so we use the name build
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
name: RTLMeter
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *' # Daily, starting at 02:00 UTC
defaults:
run:
shell: bash
concurrency:
group: RTLMeter
cancel-in-progress: false
jobs:
build-gcc:
name: Build GCC
uses: ./.github/workflows/reusable-rtlmeter-build.yml
with:
runs-on: ubuntu-24.04
cc: gcc
build-clang:
name: Build Clang
uses: ./.github/workflows/reusable-rtlmeter-build.yml
with:
runs-on: ubuntu-24.04
cc: clang
run-gcc:
name: Run GCC | ${{ matrix.cases }}
needs: build-gcc
uses: ./.github/workflows/reusable-rtlmeter-run.yml
with:
runs-on: ubuntu-24.04
cc: gcc
cases: ${{ matrix.cases }}
compileArgs: ""
executeArgs: ""
strategy:
fail-fast: false
max-parallel: 2
matrix:
cases:
- "NVDLA:*"
- "OpenPiton:1x1:*"
- "OpenPiton:2x2:*"
- "OpenPiton:4x4:*"
# - "OpenTitan:*"
- "VeeR-EH1:asic*"
- "VeeR-EH1:default*"
- "VeeR-EH1:hiperf*"
- "VeeR-EH2:asic*"
- "VeeR-EH2:default*"
- "VeeR-EH2:hiperf*"
- "VeeR-EL2:asic*"
- "VeeR-EL2:default*"
- "VeeR-EL2:hiperf*"
- "Vortex:mini:*"
- "Vortex:sane:*"
# - "XiangShan:default-chisel3:* !*:linux"
# - "XiangShan:default-chisel6:* !*:linux"
- "XiangShan:mini-chisel3:* !*:linux"
# - "XiangShan:mini-chisel6:* !*:linux"
- "XuanTie-E902:*"
- "XuanTie-E906:*"
- "XuanTie-C906:*"
- "XuanTie-C910:*"
run-clang:
name: Run Clang | ${{ matrix.cases }}
needs: build-clang
uses: ./.github/workflows/reusable-rtlmeter-run.yml
with:
runs-on: ubuntu-24.04
cc: clang
cases: ${{ matrix.cases }}
compileArgs: "--threads 4"
executeArgs: ""
strategy:
fail-fast: false
max-parallel: 2
matrix:
cases:
- "NVDLA:*"
- "OpenPiton:1x1:*"
- "OpenPiton:2x2:*"
- "OpenPiton:4x4:*"
# - "OpenTitan:*"
- "VeeR-EH1:asic*"
- "VeeR-EH1:default*"
- "VeeR-EH1:hiperf*"
- "VeeR-EH2:asic*"
- "VeeR-EH2:default*"
- "VeeR-EH2:hiperf*"
- "VeeR-EL2:asic*"
- "VeeR-EL2:default*"
- "VeeR-EL2:hiperf*"
- "Vortex:mini:*"
- "Vortex:sane:*"
- "XiangShan:default-chisel3:* !*:linux"
- "XiangShan:default-chisel6:* !*:linux"
- "XiangShan:mini-chisel3:* !*:linux"
- "XiangShan:mini-chisel6:* !*:linux"
- "XuanTie-E902:*"
- "XuanTie-E906:*"
- "XuanTie-C906:*"
- "XuanTie-C910:*"
combine-results:
name: Combine results
needs:
- run-gcc
- run-clang
if: ${{ always() }} # Run even if dependencies failed
runs-on: ubuntu-24.04
steps:
- name: Download all GCC results
uses: actions/download-artifact@v4
with:
pattern: rtlmeter-results-ubuntu-24.04-gcc-*
path: all-results-gcc-${{ github.run_id }}
merge-multiple: true
- name: Download all Clang results
uses: actions/download-artifact@v4
with:
pattern: rtlmeter-results-ubuntu-24.04-clang-*
path: all-results-clang-${{ github.run_id }}
merge-multiple: true
- name: Tar up results
run: |
# Ensure combined result directories exists in case of no results
mkdir -p all-results-gcc-${{ github.run_id }}
mkdir -p all-results-clang-${{ github.run_id }}
ls -la all-results*
# Tar up each directory
tar --posix -c -z -f all-results-gcc-${{ github.run_id }}.tar.gz all-results-gcc-${{ github.run_id }}
tar --posix -c -z -f all-results-clang-${{ github.run_id }}.tar.gz all-results-clang-${{ github.run_id }}
- name: Upload combined GCC results
uses: actions/upload-artifact@v4
with:
path: all-results-gcc-${{ github.run_id }}.tar.gz
name: "all-results-gcc"
overwrite: true
retention-days: 30
- name: Upload combined Clang results
uses: actions/upload-artifact@v4
with:
path: all-results-clang-${{ github.run_id }}.tar.gz
name: "all-results-clang"
overwrite: true
retention-days: 30
+3 -6
View File
@@ -16,14 +16,14 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) # Use MSVC_RUNTIME_LIBRARY to select the runtime
project(
Verilator
VERSION 5.032
VERSION 5.036
HOMEPAGE_URL https://verilator.org
LANGUAGES CXX
)
# Set default build type to Release if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
option(
@@ -134,10 +134,7 @@ configure_package_config_file(
INSTALL_DESTINATION .
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/verilator-config.cmake
DESTINATION .
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/verilator-config.cmake DESTINATION .)
configure_package_config_file(
verilator-config-version.cmake.in
+158 -18
View File
@@ -8,6 +8,146 @@ The changes in each Verilator version are described below. The
contributors that suggested a given feature are shown in []. Thanks!
Verilator 5.036 2025-04-27
==========================
**Important:**
* Change `--output-groups` to default to value of `--build-jobs` (#5751).
Those using build farms may need to now use `--output-groups 0` or otherwise.
* Support user-defined primitives (UDPs) (#468) (#5807) (#5936). [Zhou Shen, Krzysztof Sychla, et al]
* Add `--trace-saif` for SAIF power traces (#5812) (#5914). [Mateusz Gancarz]
**Other:**
* Change `--trace` to `--trace-vcd`.
* Support simple `checker` blocks (#4066). [Srinivasan Venkataramanan]
* Support force/release with a variable reference (#5721) (#5810). [Bartłomiej Chmiel, Antmicro Ltd.]
* Support constraint random for StructArray (#5805) (#5937). [Yilou Wang]
* Support command-line overriding `define (#5900) (#5908). [Brian Li]
* Support soft unions (#5912) (#5932). [Robin Heinemann]
* Support `$setuphold` (#5884). [Krzysztof Sychla]
* Support assigning unpacked arrays to queues (#5924) (#5928). [Brian Li]
* Support `systemc_interface and related inside `class`.
* Support class extends with arguments.
* Add multi-thread hierarchical simulation (#2583) (#5871). [Bartłomiej Chmiel, Antmicro Ltd.]
* Add check for `let` misused in statement context (#5733).
* Add used language to `--preproc-resolve` output (#5795). [Kamil Rakoczy, Antmicro Ltd.]
* Add `--make json` to enable integration with non-make/cmake build systems (#5799). [Andrew Voznytsa]
* Add numactl-like automatic assignment of processor affinity (#5911).
* Add ccache support for generated cmake files (#5926) (#5930). [Andrew Voznytsa]
* Add visualization of multi-threaded waiting time with verilator_gantt (#5929). [Bartłomiej Chmiel, Antmicro Ltd.]
* Add suggesting isolate_assignments to UNOPTFLAT (#5942). [John Khoo]
* Add profiling of hierarchical mtasks with verilator_gantt (#5956). [Bartłomiej Chmiel, Antmicro Ltd.]
* Add empty veriuser.h for legacy compatibility.
* Add DEPRECATED warning on `--xml-only` and `--xml-output`.
* Remove unused gtkwave/wavealloca.h. [Geza Lore]
* Optimize automatic splitting of some packed variables (#5843). [Geza Lore]
* Optimize trigger vector in whole words (#5857). [Geza Lore]
* Fix parameters referencing interface fields (#1593) (#5910). [Ryszard Rozak, Antmicro Ltd.]
* Fix interface array assignments (#5270) (#5633) (#5869). [Nick Brereton]
* Fix change detection at time 0 (#5499) (#5864). [Geza Lore]
* Fix foreach of associative array inside a constraint block (#5727) (#5841). [Yilou Wang]
* Fix reset of automatic function variables (#5747). [Augustin Fabre]
* Fix invalid code motion over branches (#5811) (#5814). [Geza Lore]
* Fix sorting of wide SenItems (#5816). [Geza Lore]
* Fix tcmalloc static link and non-22.04 builds (#5817) (#5818). [Geza Lore]
* Fix error on out-of-range lvalue part select (#5820).
* Fix UNOPTFLAT warnings with `--coverage-trace` and always_comb (#5821).
* Fix function locals in SenExprBuilder (#5822). [Geza Lore]
* Fix type_id package scope resolution (#5826). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix `rand_mode` method with cast (#5831).
* Fix invalidating variable caches in SenExprBulider (#5834) (#5835). [Geza Lore]
* Fix assignment pattern as function argument (#5839).
* Fix checking built-in method arguments (#5839).
* Fix splitting of packed ports with non-zero based ranges (#5842). [Geza Lore]
* Fix delays inside interface functions, and classes inside interfaces (#5846).
* Fix NBA shared flag reuse (#5848). [Geza Lore]
* Fix multiple expression coverage issues (#5849 partial) (#5867) (#5870). [Todd Strader]
* Fix unresolved typedefs as parameters (#5850). [Eugene Feinberg, Brian Li]
* Fix removal of callbacks no longer in current list (#5851) (#5852). [Gilberto Abram]
* Fix segmentation fault on member compare (#5853).
* Fix recursive error on virtual interfaces (#5854). [Yilou Wang]
* Fix streaming of unpacked arrays concatenations (#5856). [Ryszard Rozak, Antmicro Ltd.]
* Fix Windows paths in Perl (#5858) (#5860). [Tobias Jensen]
* Fix algorithm header portability in V3Os.cpp (for std::replace) (#5861). [William D. Jones]
* Fix `$fscanf` not returning -1 on EOF (#5881).
* Fix PGO profiling for multi-threaded hierarchical scenarios (#5888). [Bartłomiej Chmiel, Antmicro Ltd.]
* Fix V3Gate assertion on eliminated circular logic (#5889) (#5898). [Geza Lore]
* Fix process comparisons (#5896).
* Fix ccache with clang (#5899). [Geza Lore]
* Fix delayed assignment malformed LHS assertion (#5904).
* Fix segfault in fork synchronization (#5906). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix `new this` (#5909).
* Fix assignments with stream expressions and unpacked arrays (#5915). [Ryszard Rozak, Antmicro Ltd.]
* Fix LATCH warning for automatic variables (#5918). [Yutetsu TAKATSUKASA]
* Fix %% on elaboration severity tasks (#5922). [Ethan Sifferman]
* Fix port default values with `--coverage-line` creating `0=0` (#5920). [Drew Ranck]
* Fix vlSelf error on fork repeats (#5927). [Drew Ranck]
* Fix missing C++ regeneration when Verilog files are updated (#5934). [Zhouyi Shen]
* Fix stream expressions (#5938). [Ryszard Rozak, Antmicro Ltd.]
* Fix packed selection using over 32-bit index (#5957).
Verilator 5.034 2025-02-24
==========================
**Important:**
* This is likely the last version to support Ubuntu 20.04, which is at end-of-life.
* Add expression coverage (#4677) (#5719). [Todd Strader]
**Other:**
* Add `COVERIGN` warning, as a more specific UNSUPPORTED error.
* Add `--public-ignore` to ignore public metacomments (#5716). [Andrew Nolte]
* Add `--preproc-token-limit` (#5768). [Krzysztof Bieganski, Antmicro Ltd.]
* Add lint error on importing package within a class (#5634) (#5679). [Nick Brereton]
* Add `--preproc-resolve` for modules in preprocessor output (#5789). [Kamil Rakoczy, Antmicro Ltd.]
* Support multidimensional array access via VPI (#2812) (#5573). [Krzysztof Starecki]
* Support nested classes (#4178) (#5778). [Kamil Rakoczy, Antmicro Ltd.]
* Support VPI array accessors (#5612). [Moubarak Jeje]
* Support unpacked structure constrained randomization (#5657) (#5759). [Yilou Wang]
* Support generated classes (#5665). [Shou-Li Hsu]
* Support constraints on associative array user-defined keys (#5671) (#5729). [Yilou Wang]
* Support `+incdir` with multiple directories.
* Support integer atom type ports in `--hierarchical` (#5748). [Bartłomiej Chmiel, Antmicro Ltd.]
* Support constrained random for arrays in structs (#5765) (#5802). [Yilou Wang]
* Support selects on arbitrary string expressions (#5773). [Krzysztof Bieganski, Antmicro Ltd.]
* Support side effects of form 'variable[index_function()]++'.
* Improve hierarchical DPI wrapper scheduling performance (#2583) (#5734). [Bartłomiej Chmiel, Antmicro Ltd.]
* Improve VPI write errors (#5712). [Andrew Nolte]
* Improve `resetall support (#5728) (#5730). [Ethan Sifferman]
* Optimize labels as final `if` block statements (#5744).
* Optimize empty function definition bodies (#5750).
* Optimize splitting trigger computation and dump (#5798). [Geza Lore]
* Fix error message when call task as a function (#3089). [Matthew Ballance]
* Fix force VPI public signal visibility (#5225). [Frédéric Requin]
* Fix VPI iteration over hierarchy (#5314) (#5731). [Natan Kreimer]
* Fix constrained random for > 64-bit associative arrays (#5670) (#5682). [Yilou Wang]
* Fix mis-optimizing away `$urandom` (#5703). [Parker Schless]
* Fix packages with `--public-depth 1` (#5708). [Andrew Nolte]
* Fix V3Simulate constant reuse (#5709). [Geza Lore]
* Fix man pages what-is section (#5710). [Ahmed El-Mahmoudy]
* Fix pattern assignment to real inside struct (#5713).
* Fix %p format output for real inside struct (#5713).
* Fix segfault when only enum value referenced in package (#5714). [Dan Katz]
* Fix `BLKSEQ` on suspendable processes (#5722). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix vpiDefName issues with non-inlined scopes and dpi conflicts (#5732). [Andrew Nolte]
* Fix inlined expression with assignment under LHS of NBA (#5736) (#5740). [Geza Lore]
* Fix duplicate-named class variable equivalence (#5737).
* Fix `-j` ignored after `-f` (#5749). [Luca Colagrande]
* Fix handling forced assigns in V3Life (#5757). [Bartłomiej Chmiel, Antmicro Ltd.]
* Fix VFileContent reference count (#5769) (#5771). [Dave Sargeant]
* Fix ignoring joins in stringify in preprocessor (#5777). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix unpacked split_var (#5782) (#5785). [Yutetsu TAKATSUKASA]
* Fix time import error on time parameters (#5786). [Luca Colagrande]
* Fix dpi context functions (#5788). [Ryszard Rozak, Antmicro Ltd.]
* Fix `$monitor` with dotted references (#5794). [Ahmed Elzeftawi]
* Fix parsing input wire with default and range (#5800). [RJ Cunningham]
* Fix matching language extension options including dots.
Verilator 5.032 2025-01-01
==========================
@@ -136,7 +276,7 @@ Verilator 5.030 2024-10-27
* Fix short-circuiting with associative array access (#5484). [Ethan Sifferman]
* Fix short-circuiting on method calls (#5486). [Ethan Sifferman]
* Fix exponential concatenate performance (#5488). [Arkadiusz Kozdra, Antmicro Ltd.]
* Fix V3Table trying to generate 'x' bits in the lookup table. (#5491). [Geza Lore]
* Fix V3Table trying to generate 'x' bits in the lookup table (#5491). [Geza Lore]
* Fix randomize with foreach constraints (#5492). [Arkadiusz Kozdra, Antmicro Ltd.]
* Fix explicit CMAKE_INSTALL_PREFIX usages (#5500). [Fabian Keßler]
* Fix configure inserting absolute paths for Python and Perl (#5504) (#5505). [Nathan Graybeal]
@@ -194,7 +334,7 @@ Verilator 5.028 2024-08-21
* Add parsing but otherwise ignore std::randomize (#5354). [Arkadiusz Kozdra, Antmicro Ltd.]
* Add Verilated cc define when `--timing` used (#5383). [Kaleb Barrett]
* Improve emitted code to use a reference for VlSelf (#5254). [Yangyu Chen]
* Fix monitor block sensitivity items (#4400) (#5294). [Udaya Raj Subedi]
* Fix monitor block sensitivity items (#4040) (#4400) (#5294). [Udaya Raj Subedi]
* Fix fusing macro arguments to not ignore whitespace (#5061). [Tudor Timi]
* Fix optimized-out sensitivity trees with `--timing` (#5080) (#5349). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix classes/modules of case-similar names (#5109). [Arkadiusz Kozdra]
@@ -221,7 +361,7 @@ Verilator 5.028 2024-08-21
* Fix static variable initializers in procedures (#5296). [Bartłomiej Chmiel, Antmicro Ltd.]
* Fix randomizing current object with `rand` class instance member (#5292). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix handling of rand fields not referenced in constraints (#5305). [Ryszard Rozak, Antmicro Ltd.]
* Fix Python3 path discovery in make flows to avoid mixing system and user python interpreters (#5307) [Markus Krause]
* Fix Python3 path discovery in make flows to avoid mixing system and user python interpreters (#5307). [Markus Krause]
* Fix make flows to pass PYTHON3 (like PERL) (#5307) (#5308). [Markus Krause]
* Fix assert on wide expression (#5319) (#5324). [Varun Koyyalagunta]
* Fix output clock variable overwriting signal (#5320) (#5347). [Krzysztof Bieganski, Antmicro Ltd.]
@@ -400,7 +540,7 @@ Verilator 5.022 2024-02-24
* Fix `vpi_get()` and `vpi_get64()` to return vpiUndefined on errors (#4795). [Marlon James]
* Fix VPI parameter iteration (#4798). [Marlon James]
* Fix delays using wrong timeunit when modules inlined (#4806). [Paul Wright]
* Fix warnings in verilated_sc_trace.h for Clang. (#4807) (#4827). [Anthony Donlon]
* Fix warnings in verilated_sc_trace.h for Clang (#4807) (#4827). [Anthony Donlon]
* Fix null pointer dereference (#4810) (#4825). [Adrian Sampson]
* Fix compilation error on multi-inherited interface class usage (#4819).
* Fix maybe-uninitialized compiler warning (#4820) (#4822). [Larry Doolittle]
@@ -478,7 +618,7 @@ Verilator 5.020 2024-01-01
* Fix conflicted namespace for coroutines (#4701) (#4707). [Jinyan Xu]
* Fix compilers seeing empty input due to file system races (#4708). [Flavien Solt]
* Fix shift of > 32-bit number (#4719). [Flavien Solt]
* Fix Windows include gates in filesystem Flush implementation. (#4720). [William D. Jones]
* Fix Windows include gates in filesystem Flush implementation (#4720). [William D. Jones]
* Fix power operator with wide numbers and constants (#4721) (#4763). [Flavien Solt]
* Fix parameter passing to ports (#4723). [Ryszard Rozak, Antmicro Ltd.]
* Fix block names of nested do..while loops (#4728). [Ryszard Rozak, Antmicro Ltd.]
@@ -487,7 +627,7 @@ Verilator 5.020 2024-01-01
* Fix $finish twice to no longer exit (#4757). [Tim Hutt]
* Fix dynamic NBA conditions (#4773). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix `V3Fork` stage to run only if `--timing` is set (#4778). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix max multiply width and add runtime assertions if too small. (#4781)
* Fix max multiply width and add runtime assertions if too small (#4781).
* Fix select value too wide (#5148) (#5153). [Dercury]
@@ -1152,7 +1292,7 @@ Verilator 4.218 2022-01-17
* Support class static members (#2233).
* Support force/release (#2431) (#2593). [Shunyao CAD]
* Add 'forceable' attribute to allow forcing from C++. (#3272). [Geza Lore, Shunyao CAD]
* Add 'forceable' attribute to allow forcing from C++ (#3272). [Geza Lore, Shunyao CAD]
* Support lower dimension looping in foreach loops (#3172). [Ehab Ibrahim]
* Support up to 64 bit enums for .next/.prev/.name (#3244). [Alexander Grobman]
* Reduce .rodata footprint of trace initialization (#3250). [Geza Lore, Shunyao CAD]
@@ -1376,7 +1516,7 @@ Verilator 4.200 2021-03-12
**Major:**
* Add simulation context (VerilatedContext) to allow multiple fully independent
models to be in the same process. Please see the updated examples. (#2660)
models to be in the same process. Please see the updated examples (#2660).
* Add context->time() and context->timeInc() API calls, to set simulation time.
These now are recommended in place of the legacy sc_time_stamp().
@@ -1387,7 +1527,7 @@ Verilator 4.200 2021-03-12
* Fix slice-assign overflow (#2803) (#2811). [David Turner]
* Fix interface array connection ordering broken in v4.110 (#2827). [Don Owen]
* Fix or-reduction on different scopes broken in 4.110 (#2828). [Yinan Xu]
* Fix MSVC++ compile error. (#2831) (#2833) [Drew Taussig]
* Fix MSVC++ compile error (#2831) (#2833). [Drew Taussig]
Verilator 4.110 2021-02-25
@@ -1442,7 +1582,7 @@ Verilator 4.108 2021-01-10
* Fix vpiLeftRange on little-endian memories (#2696). [Marlon James]
* Fix VPI module tree (#2704). [Todd Strader]
* Fix vpi_release_handle to be called implicitly per IEEE (#2706).
* Fix to allow inheriting 'VerilatedVcdFile' class. (#2720) [HyungKi Jeong]
* Fix to allow inheriting 'VerilatedVcdFile' class (#2720). [HyungKi Jeong]
* Fix $urandom_range maximum value (#2723). [Nandu Raj]
* Fix tracing empty sc module (#2729).
* Fix generate for unrolling to be signed (#2730). [yanx21]
@@ -1548,11 +1688,11 @@ Verilator 4.040 2020-08-15
**Minor:**
* Fix arrayed interfaces, broke in 4.038 (#2468). [Josh Redford]
* Support $stable, $rose and $fell. (#2148) (#2501) [Peter Monsson]
* Support $stable, $rose and $fell (#2148) (#2501). [Peter Monsson]
* Support simple function localparams (#2461). [James Hanlon]
* Miscellaneous parsing error changes towards UVM support.
* Fix arrayed interfaces (#2469). [Josh Redford]
* Fix protect lib VCS warning. (#2479) [Julien Margetts]
* Fix protect lib VCS warning (#2479). [Julien Margetts]
* Fix combining different-width parameters (#2484). [abirkmanis]
* Fix protect-lib without sequential logic (#2492). [Yutetsu TAKATSUKASA]
* Fix V3Unknown from running with flat XML output (#2494). [James Hanlon]
@@ -1608,16 +1748,16 @@ Verilator 4.036 2020-06-06
waivers to the warnings emitted during a Verilator run.
* Support verilator_coverage --write-info for lcov HTML reports.
* Line Coverage now tracks all statement lines, not just branch lines.
* The run-time library is now compiled with -Os by default. (#2369, #2373)
* The run-time library is now compiled with -Os by default (#2369, #2373).
* Support multi channel descriptor I/O (#2190) [Stephen Henry]
* Support $countbits. (#2287) [Yossi Nivin]
* Support $isunbounded and parameter $. (#2104)
* Support $countbits (#2287). [Yossi Nivin]
* Support $isunbounded and parameter $ (#2104).
* Support unpacked array .sum and .product.
* Support prefix/postfix increment/decrement. (#2223) [Maciej Sobkowski]
* Support prefix/postfix increment/decrement (#2223). [Maciej Sobkowski]
* Fix FST tracing of little bit endian signals. [Geza Lore]
* Fix +: and -: on unpacked arrays. (#2304) [engr248]
* Fix +: and -: on unpacked arrays (#2304). [engr248]
* Fix $isunknown with constant Z's.
* Fix queues and dynamic array wide ops. (#2352) [Vassilis Papaefstathiou]
* Fix queues and dynamic array wide ops (#2352). [Vassilis Papaefstathiou]
Verilator 4.034 2020-05-03
+7 -2
View File
@@ -192,7 +192,7 @@ examples: all_nomsg
# Docs
.PHONY: docs
docs: info
docs: info $(VL_INST_MAN_FILES)
info: $(INFOS)
@@ -201,7 +201,8 @@ verilator.1: ${srcdir}/bin/verilator
verilator_coverage.1: ${srcdir}/bin/verilator_coverage
pod2man $< $@
%.1: ${srcdir}/bin/%
help2man --no-info --no-discard-stderr --version-string=- $< -o $@
help2man --no-info --no-discard-stderr --version-string=- \
-n "$(shell $< --help | head -n 3 | tail -n 1)" $< -o $@
.PHONY: verilator.html
verilator.html:
@@ -527,6 +528,8 @@ GERSEMI_FLAGS = -i
format-cmake:
$(GERSEMI) $(GERSEMI_FLAGS) $(CMAKE_FILES)
format-yaml: yamlfix
PYLINT = pylint
PYLINT_FLAGS = --recursive=n --score=n --disable=R0801
PYLINT_TEST_FLAGS = $(PYLINT_FLAGS) --disable=C0103,C0114,C0116,C0209,C0411,C0413,C0301,R0801,R0912,R0915,R0916,R1702,W0511,W0621
@@ -594,6 +597,8 @@ clean mostlyclean distclean maintainer-clean::
rm -f *.tex
rm -rf examples/*/obj_dir* examples/*/logs
rm -rf test_*/obj_dir
rm -rf src/*.tidy include/*.tidy examples/*/*.tidy
rm -rf .ruff_cache
rm -rf nodist/fuzzer/dictionary
rm -rf nodist/obj_dir
rm -rf verilator.txt
+2 -4
View File
@@ -1,7 +1,7 @@
.. Github doesn't render images unless absolute URL
.. Do not know of a conditional tag, "only: github" nor "github display" works
|badge1| |badge2| |badge3| |badge4| |badge5| |badge6| |badge7|
|badge1| |badge2| |badge3| |badge4| |badge5| |badge7|
.. |badge1| image:: https://img.shields.io/badge/Website-Verilator.org-181717.svg
:target: https://verilator.org
@@ -13,8 +13,6 @@
:target: https://repology.org/project/verilator/versions
.. |badge5| image:: https://img.shields.io/docker/pulls/verilator/verilator
:target: https://hub.docker.com/r/verilator/verilator
.. |badge6| image:: https://api.codacy.com/project/badge/Grade/fa78caa433c84a4ab9049c43e9debc6f
:target: https://www.codacy.com/gh/verilator/verilator
.. |badge7| image:: https://github.com/verilator/verilator/workflows/build/badge.svg
:target: https://github.com/verilator/verilator/actions?query=workflow%3Abuild
@@ -134,7 +132,7 @@ Related Projects
- `GTKwave <http://gtkwave.sourceforge.net/>`_ - Waveform viewer for
Verilator traces.
- `Icarus Verilog`_ - Icarus is a full-featured interpreted Verilog
- `Icarus Verilog`_ - Icarus is a highly-featured interpreted Verilog
simulator. If Verilator does not support your needs, perhaps Icarus may.
+27 -21
View File
@@ -256,7 +256,7 @@ sub sh_escape {
# This is similar to quotemeta() but less aggressive.
# There's no need to escape hyphens, periods, or forward slashes
# for the shell as these have no special meaning to the shell.
$arg =~ s/([^0-9a-zA-Z_\-\+\=\.\/])/\\$1/g;
$arg =~ s/([^0-9a-zA-Z_\-\+\=\.\/:])/\\$1/g;
return $arg;
}
@@ -269,8 +269,7 @@ __END__
=head1 NAME
Verilator - Translate and simulate SystemVerilog code using C++/SystemC
Verilator - Lint, compile and simulate SystemVerilog code using C++/SystemC
=head1 SYNOPSIS
@@ -329,6 +328,8 @@ detailed descriptions of these arguments.
--compiler-include Include additional header in the precompiled one
--converge-limit <loops> Tune convergence settle time
--coverage Enable all coverage
--coverage-expr Enable expression coverage
--coverage-expr-max <value> Maximum permutations allowed for an expression
--coverage-line Enable line coverage
--coverage-max-width <width> Maximum array depth for coverage
--coverage-toggle Enable toggle coverage
@@ -340,11 +341,12 @@ detailed descriptions of these arguments.
--no-debug-leak Disable leaking memory in --debug mode
--debugi <level> Enable debugging at a specified level
--debugi-<srcfile> <level> Enable debugging a source file at a level
--decorations <level> Set output comment and spacing level
--no-decoration Disable comments and lower spacing level
--decorations <level> Set output comment and spacing level
--default-language <lang> Default language to parse
+define+<var>=<value> Set preprocessor define
--dpi-hdr-only Only produce the DPI header file
--dump-<srcfile> Enable dumping everything in source file
--dump-defines Show preprocessor defines with -E
--dump-dfg Enable dumping DfgGraphs to .dot files
--dump-graph Enable dumping V3Graphs to .dot files
@@ -352,12 +354,11 @@ detailed descriptions of these arguments.
--dump-tree-addrids Use short identifiers instead of addresses
--dump-tree-dot Enable dumping Ast .tree.dot debug files
--dump-tree-json Enable dumping Ast .tree.json files and .tree.meta.json file
--dump-<srcfile> Enable dumping everything in source file
--dumpi-<srcfile> <level> Enable dumping everything in source file at level
--dumpi-dfg <level> Enable dumping DfgGraphs to .dot files at level
--dumpi-graph <level> Enable dumping V3Graphs to .dot files at level
--dumpi-tree <level> Enable dumping Ast .tree files at level
--dumpi-tree-json <level> Enable dumping Ast .tree.json files at level
--dumpi-<srcfile> <level> Enable dumping everything in source file at level
-E Preprocess, but do not compile
--emit-accessors Emit getter and setter methods for model top class
--error-limit <value> Abort after this number of errors
@@ -375,8 +376,8 @@ detailed descriptions of these arguments.
--gdb Run Verilator under GDB interactively
--gdbbt Run Verilator under GDB for backtrace
--generate-key Create random key for --protect-key
--getenv <var> Get environment variable with defaults
--get-supported <feature> Get if feature is supported
--getenv <var> Get environment variable with defaults
--help Show this help
--hierarchical Enable hierarchical Verilation
--hierarchical-params-file <name> Internal option that specifies parameters file for hier blocks
@@ -386,6 +387,11 @@ detailed descriptions of these arguments.
--inline-mult <value> Tune module inlining
--instr-count-dpi <value> Assumed dynamic instruction count of DPI imports
-j <jobs> Parallelism for --build-jobs/--verilate-jobs
--no-json-edit-nums Don't dump editNum in .tree.json files
--no-json-ids Don't use short identifiers instead of adresses/paths in .tree.json
--json-only Create JSON parser output (.tree.json and .meta.json)
--json-only-meta-output .tree.meta.json output filename
--json-only-output .tree.json output filename
--l2-name <value> Verilog scope name of the top module
--language <lang> Default language standard to parse
-LDFLAGS <flags> Linker pre-object arguments for makefile
@@ -393,20 +399,20 @@ detailed descriptions of these arguments.
+libext+<ext>+[ext]... Extensions for finding modules
--lint-only Lint, but do not make output
--localize-max-size <value> Tune localize optimization variable size
--make <build-tool> Generate scripts for specified build tool
-MAKEFLAGS <flags> Arguments to pass to make during --build
--main Generate C++ main() file
--main-top-name Specify top name passed to Verilated model in generated C++ main
--make <build-tool> Generate scripts for specified build tool
-MAKEFLAGS <flags> Arguments to pass to make during --build
--max-num-width <value> Maximum number width (default: 64K)
--Mdir <directory> Name of output object directory
--MMD Create .d dependency files
--mod-prefix <topname> Name to prepend to lower classes
--MP Create phony dependency targets
+notimingchecks Ignored
-o <executable> Name of final executable
-O0 Disable optimizations
-O3 High-performance optimizations
-O<optimization-letter> Selectable optimizations
-o <executable> Name of final executable
--output-groups <numfiles> Group .cpp files into larger ones
--output-split <statements> Split .cpp files into pieces
--output-split-cfuncs <statements> Split model functions
@@ -422,6 +428,8 @@ detailed descriptions of these arguments.
--pipe-filter <command> Filter all input through a script
--pp-comments Show preprocessor comments with -E
--prefix <topname> Name of top-level class
--preproc-resolve Include all found modules in the output with -E
--preproc-token-limit Maximum tokens on a line allowed by preprocessor
--private Debugging; see docs
--prof-c Compile C++ code with profiling
--prof-cfuncs Name functions for profiling
@@ -432,8 +440,9 @@ detailed descriptions of these arguments.
--protect-lib <name> Create a DPI protected library
--public Mark signals as public; see docs
--public-depth <level> Mark public to specified module depth
--public-params Mark all parameters as public_flat
--public-flat-rw Mark all variables, etc as public_flat_rw
--public-ignore Ignore all public comment markings
--public-params Mark all parameters as public_flat
-pvalue+<name>=<value> Overwrite toplevel parameter
--quiet Minimize additional printing
--quiet-exit Don't print the command on failure
@@ -458,23 +467,25 @@ detailed descriptions of these arguments.
--threads <threads> Enable multithreading
--threads-dpi <mode> Enable multithreaded DPI
--threads-max-mtasks <mtasks> Tune maximum mtask partitioning
--timing Enable timing support
--no-timing Disable timing support
--timescale <timescale> Sets default timescale
--timescale-override <timescale> Overrides all timescales
--timing Enable timing support
--no-timing Disable timing support
--top <topname> Alias of --top-module
--top-module <topname> Name of top-level input module
--trace Enable waveform creation
--trace Enable VCD waveform creation
--trace-coverage Enable tracing of coverage
--trace-depth <levels> Depth of tracing
--trace-fst Enable FST waveform creation
--trace-max-array <depth> Maximum array depth for tracing
--trace-max-width <width> Maximum bit width for tracing
--trace-params Enable tracing of parameters
--trace-saif Enable SAIF file creation
--trace-structs Enable tracing structure names
--trace-threads <threads> Enable FST waveform creation on separate threads
--no-trace-top Do not emit traces for signals in the top module generated by verilator
--trace-underscore Enable tracing of _signals
--trace-vcd Enable VCD waveform creation
-U<var> Undefine preprocessor define
--no-unlimited-stack Don't disable stack size limit
--unroll-count <loops> Tune maximum loop iterations
@@ -483,8 +494,8 @@ detailed descriptions of these arguments.
-V Verbose version and config
-v <filename> Verilog library
--valgrind Run Verilator under valgrind
--verilate-jobs Job threads for Verilation stage
--no-verilate Skip Verilation and just compile previously Verilated code
--verilate-jobs Job threads for Verilation stage
+verilog1995ext+<ext> Synonym for +1364-1995ext+<ext>
+verilog2001ext+<ext> Synonym for +1364-2001ext+<ext>
--version Show program version and exits
@@ -506,11 +517,6 @@ detailed descriptions of these arguments.
--x-assign <mode> Assign non-initial Xs to this value
--x-initial <mode> Assign initial Xs to this value
--x-initial-edge Enable initial X->0 and X->1 edge triggers
--no-json-edit-nums Don't dump editNum in .tree.json files
--no-json-ids Don't use short identifiers instead of adresses/paths in .tree.json
--json-only Create JSON parser output (.tree.json and .meta.json)
--json-only-output .tree.json output filename
--json-only-meta-output .tree.meta.json output filename
--xml-only Create XML parser output
--xml-output XML output filename
-y <dir> Directory to search for modules
@@ -522,9 +528,9 @@ description of these arguments.
=for VL_SPHINX_EXTRACT "_build/gen/args_verilated.rst"
+verilator+coverage+file+<filename> Set coverage output filename
+verilator+debug Enable debugging
+verilator+debugi+<value> Enable debugging at a level
+verilator+coverage+file+<filename> Set coverage output filename
+verilator+error+limit+<value> Set error limit
+verilator+help Show help
+verilator+noassert Disable assert checking
+123 -48
View File
@@ -8,17 +8,27 @@ import collections
import math
import re
import statistics
from collections import OrderedDict
# from pprint import pprint
Sections = []
Sections = OrderedDict()
LongestVcdStrValueLength = 0
Threads = collections.defaultdict(lambda: []) # List of records per thread id
Mtasks = collections.defaultdict(lambda: {'elapsed': 0, 'end': 0})
Cpus = collections.defaultdict(lambda: {'mtask_time': 0})
Global = {'args': {}, 'cpuinfo': collections.defaultdict(lambda: {}), 'stats': {}}
Global = {
'args': {},
'cpuinfo': collections.defaultdict(lambda: {}),
'info': {
'numa': 'no data'
},
'stats': {}
}
ElapsedTime = None # total elapsed time
ExecGraphTime = 0 # total elapsed time excuting an exec graph
ExecGraphTime = 0 # total elapsed time executing an exec graph
WaitingTime = 0 # total elapsed time waiting for mtasks
ExecGraphIntervals = [] # list of (start, end) pairs
ThreadScheduleWaitIntervals = [] # list of (start, tick, ecpu) pairs
######################################################################
@@ -27,23 +37,29 @@ def read_data(filename):
with open(filename, "r", encoding="utf8") as fh:
re_thread = re.compile(r'^VLPROFTHREAD (\d+)$')
re_record = re.compile(r'^VLPROFEXEC (\S+) (\d+)(.*)$')
re_payload_mtaskBegin = re.compile(r'id (\d+) predictStart (\d+) cpu (\d+)')
re_payload_mtaskEnd = re.compile(r'id (\d+) predictCost (\d+)')
# The hierBlock argument is optional
re_payload_mtaskBegin = re.compile(
r'id (\d+) predictStart (\d+) cpu (\d+)(?: hierBlock)?\s*(\w+)?')
re_payload_mtaskEnd = re.compile(r'predictCost (\d+)')
re_payload_wait = re.compile(r'cpu (\d+)')
re_arg1 = re.compile(r'VLPROF arg\s+(\S+)\+([0-9.]*)\s*')
re_arg2 = re.compile(r'VLPROF arg\s+(\S+)\s+([0-9.]*)\s*$')
re_stat = re.compile(r'VLPROF stat\s+(\S+)\s+([0-9.]+)')
re_info = re.compile(r'VLPROF info\s+(\S+)\s+(.*)$')
re_stat = re.compile(r'VLPROF stat\s+(\S+)\s+(\S+)')
re_proc_cpu = re.compile(r'VLPROFPROC processor\s*:\s*(\d+)\s*$')
re_proc_dat = re.compile(r'VLPROFPROC ([a-z_ ]+)\s*:\s*(.*)$')
cpu = None
thread = 0
execGraphStart = None
global LongestVcdStrValueLength
global ExecGraphTime
global WaitingTime
ExecGraphStack = []
SectionStack = []
mTaskThread = {}
MtasksStack = []
ThreadScheduleWait = collections.defaultdict(list)
for line in fh:
recordMatch = re_record.match(line)
@@ -60,44 +76,57 @@ def read_data(filename):
SectionStack.pop()
Sections[thread].append((tick, tuple(SectionStack)))
elif kind == "MTASK_BEGIN":
mtask, predict_start, ecpu = re_payload_mtaskBegin.match(payload).groups()
mtask, predict_start, ecpu, hier_block = re_payload_mtaskBegin.match(
payload).groups()
hier_block = "" if hier_block is None else hier_block
mtask = int(mtask)
predict_start = int(predict_start)
ecpu = int(ecpu)
mTaskThread[mtask] = thread
records = Threads[thread]
assert not records or records[-1]['start'] <= records[-1]['end'] <= tick
records.append({
'start': tick,
'mtask': mtask,
'predict_start': predict_start,
'hier_block': hier_block,
'cpu': ecpu
})
Mtasks[mtask]['begin'] = tick
Mtasks[mtask]['thread'] = thread
Mtasks[mtask]['predict_start'] = predict_start
Mtasks[(hier_block, mtask)]['begin'] = tick
Mtasks[(hier_block, mtask)]['predict_start'] = predict_start
Mtasks[(hier_block, mtask)]['thread'] = thread
MtasksStack.append((hier_block, mtask, records[-1]))
elif kind == "MTASK_END":
mtask, predict_cost = re_payload_mtaskEnd.match(payload).groups()
predict_cost, = re_payload_mtaskEnd.match(payload).groups()
mtask = int(mtask)
hier_block, mtask, record = MtasksStack.pop()
predict_cost = int(predict_cost)
begin = Mtasks[mtask]['begin']
record = Threads[mTaskThread[mtask]][-1]
begin = Mtasks[(hier_block, mtask)]['begin']
record['end'] = tick
assert record and records[-1]['start'] <= records[-1]['end'] <= tick
record['predict_cost'] = predict_cost
Mtasks[mtask]['elapsed'] += tick - begin
Mtasks[mtask]['predict_cost'] = predict_cost
Mtasks[mtask]['end'] = max(Mtasks[mtask]['end'], tick)
Mtasks[(hier_block, mtask)]['elapsed'] += tick - begin
Mtasks[(hier_block, mtask)]['predict_cost'] = predict_cost
Mtasks[(hier_block, mtask)]['end'] = max(Mtasks[(hier_block, mtask)]['end'],
tick)
elif kind == "THREAD_SCHEDULE_WAIT_BEGIN":
ecpu = int(re_payload_wait.match(payload).groups()[0])
ThreadScheduleWait[ecpu].append(tick)
elif kind == "THREAD_SCHEDULE_WAIT_END":
ecpu = int(re_payload_wait.match(payload).groups()[0])
start = ThreadScheduleWait[ecpu].pop()
WaitingTime += tick - start
ThreadScheduleWaitIntervals.append((start, tick, ecpu))
elif kind == "EXEC_GRAPH_BEGIN":
execGraphStart = tick
ExecGraphStack.append(tick)
elif kind == "EXEC_GRAPH_END":
assert ExecGraphStack, "EXEC_GRAPH_END without EXEC_GRAPH_BEGIN"
execGraphStart = ExecGraphStack.pop()
ExecGraphTime += tick - execGraphStart
ExecGraphIntervals.append((execGraphStart, tick))
execGraphStart = None
elif Args.debug:
print("-Unknown execution trace record: %s" % line)
elif re_thread.match(line):
thread = int(re_thread.match(line).group(1))
Sections.append([])
Sections[thread] = []
elif re.match(r'^VLPROF(THREAD|VERSION)', line):
pass
elif re_arg1.match(line):
@@ -106,6 +135,9 @@ def read_data(filename):
elif re_arg2.match(line):
match = re_arg2.match(line)
Global['args'][match.group(1)] = match.group(2)
elif re_info.match(line):
match = re_info.match(line)
Global['info'][match.group(1)] = match.group(2)
elif re_stat.match(line):
match = re_stat.match(line)
Global['stats'][match.group(1)] = match.group(2)
@@ -156,11 +188,13 @@ def report():
print("\nSummary:")
print(" Total elapsed time = {} rdtsc ticks".format(ElapsedTime))
print(" Parallelized code = {:.2%} of elapsed time".format(ExecGraphTime / ElapsedTime))
print(" Waiting time = {:.2%} of elapsed time".format(WaitingTime / ElapsedTime))
print(" Total threads = %d" % nthreads)
print(" Total CPUs used = %d" % ncpus)
print(" Total mtasks = %d" % len(Mtasks))
print(" Total yields = %d" % int(Global['stats'].get('yields', 0)))
report_numa()
report_mtasks()
report_cpus()
report_sections()
@@ -181,6 +215,11 @@ def report():
print()
def report_numa():
print("\nNUMA assignment:")
print(" NUMA status = %s" % Global['info']['numa'])
def report_mtasks():
if not Mtasks:
return
@@ -201,8 +240,8 @@ def report_mtasks():
long_mtask = None
predict_mtask_time = 0
predict_elapsed = 0
for mtaskId in Mtasks:
record = Mtasks[mtaskId]
for (hier_block, mtask_id) in Mtasks:
record = Mtasks[(hier_block, mtask_id)]
predict_mtask_time += record['predict_cost']
total_mtask_time += record['elapsed']
thread_mtask_time[record['thread']] += record['elapsed']
@@ -210,7 +249,8 @@ def report_mtasks():
predict_elapsed = max(predict_elapsed, predict_end)
if record['elapsed'] > long_mtask_time:
long_mtask_time = record['elapsed']
long_mtask = mtaskId
long_mtask = mtask_id
long_mtask_hier_block = hier_block
Global['predict_last_end'] = predict_elapsed
serialTime = ElapsedTime - ExecGraphTime
@@ -239,31 +279,52 @@ def report_mtasks():
max_p2e = -1000000
max_mtask = None
for mtask in sorted(Mtasks.keys()):
if Mtasks[mtask]['elapsed'] > 0:
if Mtasks[mtask]['predict_cost'] == 0:
Mtasks[mtask]['predict_cost'] = 1 # don't log(0) below
p2e_ratio = math.log(Mtasks[mtask]['predict_cost'] / Mtasks[mtask]['elapsed'])
for (hier_block, mtask_id) in sorted(Mtasks.keys()):
mtask = Mtasks[(hier_block, mtask_id)]
if mtask['elapsed'] > 0:
if mtask['predict_cost'] == 0:
mtask['predict_cost'] = 1 # don't log(0) below
p2e_ratio = math.log(mtask['predict_cost'] / mtask['elapsed'])
p2e_ratios.append(p2e_ratio)
if p2e_ratio > max_p2e:
max_p2e = p2e_ratio
max_mtask = mtask
max_mtask = mtask_id
max_hier_block = hier_block
if p2e_ratio < min_p2e:
min_p2e = p2e_ratio
min_mtask = mtask
min_mtask = mtask_id
min_hier_block = hier_block
print("\nMTask statistics:")
print(" Longest mtask id = {}".format(long_mtask))
if long_mtask_hier_block:
print(" Longest mtask id = {} from hier_block '{}'".format(long_mtask,
long_mtask_hier_block))
else:
print(" Longest mtask id = {}".format(long_mtask))
print(" Longest mtask time = {:.2%} of time elapsed in parallelized code".format(
long_mtask_time / ExecGraphTime))
print(" min log(p2e) = %0.3f" % min_p2e, end="")
print(" from mtask %d (predict %d," % (min_mtask, Mtasks[min_mtask]['predict_cost']), end="")
print(" elapsed %d)" % Mtasks[min_mtask]['elapsed'])
if min_hier_block:
print(" from hier_block '%s' mtask %d (predict %d," %
(min_hier_block, min_mtask, Mtasks[(min_hier_block, min_mtask)]['predict_cost']),
end="")
else:
print(" from mtask %d (predict %d," %
(min_mtask, Mtasks[(min_hier_block, min_mtask)]['predict_cost']),
end="")
print(" elapsed %d)" % Mtasks[(min_hier_block, min_mtask)]['elapsed'])
print(" max log(p2e) = %0.3f" % max_p2e, end="")
print(" from mtask %d (predict %d," % (max_mtask, Mtasks[max_mtask]['predict_cost']), end="")
print(" elapsed %d)" % Mtasks[max_mtask]['elapsed'])
if max_hier_block:
print(" from hier_block '%s' mtask %d (predict %d," %
(max_hier_block, max_mtask, Mtasks[(max_hier_block, max_mtask)]['predict_cost']),
end="")
else:
print(" from mtask %d (predict %d," %
(max_mtask, Mtasks[(max_hier_block, max_mtask)]['predict_cost']),
end="")
print(" elapsed %d)" % Mtasks[(max_hier_block, max_mtask)]['elapsed'])
stddev = statistics.pstdev(p2e_ratios)
mean = statistics.mean(p2e_ratios)
@@ -308,7 +369,7 @@ def report_cpus():
def report_sections():
for thread, section in enumerate(Sections):
for thread, section in Sections.items():
if section:
print(f"\nSection profile for thread {thread}:")
report_section(section)
@@ -403,6 +464,9 @@ def write_vcd(filename):
val = buf.ljust(LongestVcdStrValueLength * 8, "0")
values[time][code] = val
def addXValue(code, time):
values[time][code] = 'x'
# Measured graph
for thread in sorted(Threads):
mcode = getCode(32, 'measured', 't%d_mtask' % thread)
@@ -427,27 +491,36 @@ def write_vcd(filename):
tStart = sorted(_['start'] for records in Threads.values() for _ in records)
tEnd = sorted(_['end'] for records in Threads.values() for _ in records)
# Measured waiting time
for (start, end, cpu) in ThreadScheduleWaitIntervals:
mcode = getCode(32, 'measured', 'cpu%d_waiting' % cpu)
addXValue(mcode, start)
addValue(mcode, end, None)
# Predicted graph
for start, end in ExecGraphIntervals:
# Find the earliest MTask start after the start point, and the
# latest MTask end before the end point, so we can scale to the
# same range
start = tStart[bisect.bisect_left(tStart, start)]
tStartIdx = bisect.bisect_left(tStart, start)
if tStartIdx >= len(tStart):
continue
start = tStart[tStartIdx]
end = tEnd[bisect.bisect_right(tEnd, end) - 1]
# Compute scale so predicted graph is of same width as interval
measured_scaling = (end - start) / Global['predict_last_end']
# Predict mtasks that fill the time the execution occupied
for mtask in Mtasks:
thread = Mtasks[mtask]['thread']
pred_scaled_start = start + int(Mtasks[mtask]['predict_start'] * measured_scaling)
for (hier_block, mtask_id) in Mtasks:
mtask = Mtasks[(hier_block, mtask_id)]
thread = mtask['thread']
pred_scaled_start = start + int(mtask['predict_start'] * measured_scaling)
pred_scaled_end = start + int(
(Mtasks[mtask]['predict_start'] + Mtasks[mtask]['predict_cost']) *
measured_scaling)
(mtask['predict_start'] + mtask['predict_cost']) * measured_scaling)
if pred_scaled_start == pred_scaled_end:
continue
mcode = getCode(32, 'predicted', 't%d_mtask' % thread)
addValue(mcode, pred_scaled_start, mtask)
addValue(mcode, pred_scaled_start, mtask_id)
addValue(mcode, pred_scaled_end, None)
parallelism['predicted'][pred_scaled_start] += 1
@@ -462,7 +535,7 @@ def write_vcd(filename):
addValue(pcode, time, value)
# Section graph
for thread, section in enumerate(Sections):
for thread, section in Sections.items():
if section:
scode = getCode(LongestVcdStrValueLength * 8, "section", f"t{thread}_trace")
dcode = getCode(32, "section", f"t{thread}_depth")
@@ -510,6 +583,8 @@ def write_vcd(filename):
value = values[time][code]
if value is None:
fh.write("bz v%x\n" % code)
elif value == 'x':
fh.write("bx v%x\n" % code)
elif isinstance(value, str):
fh.write("b%s v%x\n" % (value, code))
else:
@@ -521,7 +596,7 @@ def write_vcd(filename):
parser = argparse.ArgumentParser(
allow_abbrev=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""Create Gantt chart of multi-threaded execution.
description="""Create Gantt chart of Verilator multi-threaded execution
Verilator_gantt creates a visual representation to help analyze Verilator
#xmultithreaded simulation performance, by showing when each macro-task
+1 -1
View File
@@ -164,7 +164,7 @@ def profcfunc(filename):
parser = argparse.ArgumentParser(
allow_abbrev=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""Read gprof report created with --prof-cfuncs.
description="""Read gprof report created with Verilator --prof-cfuncs
Verilator_profcfunc reads a profile report created by gprof. The names of
the functions are then transformed, assuming the user used Verilator's
+6 -6
View File
@@ -40,7 +40,7 @@ fi
install-vcddiff() {
TMP_DIR="$(mktemp -d)"
git clone https://github.com/veripool/vcddiff "$TMP_DIR"
git -C "${TMP_DIR}" checkout e5664be5fe39d353bf3fcb50aa05214ab7ed4ac4
git -C "${TMP_DIR}" checkout dca845020668887fd13498c772939814d9264fd5
"$MAKE" -C "${TMP_DIR}"
sudo cp "${TMP_DIR}/vcddiff" /usr/local/bin
}
@@ -55,16 +55,16 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then
sudo apt-get update
sudo apt-get install ccache help2man libfl-dev ||
sudo apt-get install ccache help2man libfl-dev
if [ "$CI_RUNS_ON" = "ubuntu-20.04" ]; then
if [[ ! "$CI_RUNS_ON" =~ "ubuntu-22.04" ]]; then
# Some conflict of libunwind verison on 22.04, can live without it for now
sudo apt-get install libgoogle-perftools-dev ||
sudo apt-get install libgoogle-perftools-dev
fi
if [ "$CI_RUNS_ON" = "ubuntu-20.04" ] || [ "$CI_RUNS_ON" = "ubuntu-22.04" ] || [ "$CI_RUNS_ON" = "ubuntu-24.04" ]; then
if [[ "$CI_RUNS_ON" =~ "ubuntu-20.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-22.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-24.04" ]]; then
sudo apt-get install libsystemc libsystemc-dev ||
sudo apt-get install libsystemc libsystemc-dev
fi
if [ "$CI_RUNS_ON" = "ubuntu-22.04" ] || [ "$CI_RUNS_ON" = "ubuntu-24.04" ]; then
if [[ "$CI_RUNS_ON" =~ "ubuntu-22.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-24.04" ]]; then
sudo apt-get install bear mold ||
sudo apt-get install bear mold
fi
@@ -92,11 +92,11 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
sudo apt-get install gdb gtkwave lcov libfl-dev ccache jq z3 ||
sudo apt-get install gdb gtkwave lcov libfl-dev ccache jq z3
# Required for test_regress/t/t_dist_attributes.py
if [ "$CI_RUNS_ON" = "ubuntu-22.04" ] || [ "$CI_RUNS_ON" = "ubuntu-24.04" ]; then
if [[ "$CI_RUNS_ON" =~ "ubuntu-22.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-24.04" ]]; then
sudo apt-get install python3-clang mold ||
sudo apt-get install python3-clang mold
fi
if [ "$CI_RUNS_ON" = "ubuntu-20.04" ] || [ "$CI_RUNS_ON" = "ubuntu-22.04" ] || [ "$CI_RUNS_ON" = "ubuntu-24.04" ]; then
if [[ "$CI_RUNS_ON" =~ "ubuntu-20.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-22.04" ]] || [[ "$CI_RUNS_ON" =~ "ubuntu-24.04" ]]; then
sudo apt-get install libsystemc-dev ||
sudo apt-get install libsystemc-dev
fi
+12 -7
View File
@@ -87,7 +87,7 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
fi
# Run sanitize on Ubuntu 22.04 only
( [ "$CI_RUNS_ON" = 'ubuntu-22.04' ] || [ "$CI_RUNS_ON" = 'ubuntu-24.04' ] ) && sanitize='--sanitize' || sanitize=''
( [[ "$CI_RUNS_ON" =~ 'ubuntu-22.04' ]] || [[ "$CI_RUNS_ON" =~ 'ubuntu-24.04' ]] ) && sanitize='--sanitize' || sanitize=''
TEST_REGRESS=test_regress
if [ "$CI_RELOC" == 1 ]; then
@@ -98,6 +98,8 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
export VERILATOR_ROOT="$RELOC_DIR/relocated-install/share/verilator"
TEST_REGRESS="$RELOC_DIR/test_regress"
mv test_regress "$TEST_REGRESS"
NODIST="$RELOC_DIR/nodist"
mv nodist "$NODIST"
# Feeling brave?
find . -delete
ls -la .
@@ -107,22 +109,25 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
ccache -z
case $TESTS in
dist-vlt-0)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=0/4
;;
dist-vlt-1)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=1/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=1/4
;;
dist-vlt-2)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=2/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=2/4
;;
dist-vlt-3)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=3/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=3/4
;;
vltmt-0)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt --driver-clean" DRIVER_HASHSET=--hashset=0/3
;;
vltmt-1)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt --driver-clean" DRIVER_HASHSET=--hashset=1/3
;;
vltmt-2)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt --driver-clean" DRIVER_HASHSET=--hashset=2/3
;;
coverage-all)
nodist/code_coverage --stages 1-
+6 -3
View File
@@ -10,7 +10,7 @@
# Then 'make maintainer-dist'
#AC_INIT([Verilator],[#.### YYYY-MM-DD])
#AC_INIT([Verilator],[#.### devel])
AC_INIT([Verilator],[5.032 2025-01-01],
AC_INIT([Verilator],[5.036 2025-04-27],
[https://verilator.org],
[verilator],[https://verilator.org])
@@ -432,6 +432,7 @@ AC_SUBST(HAVE_COROUTINES)
# Flags for compiling Verilator internals including parser always
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Qunused-arguments)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Xclang -fno-pch-timestamp)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-faligned-new)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-unused-parameter)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-shadow)
@@ -469,6 +470,7 @@ CFG_CXX_FLAGS_CMAKE="-faligned-new"
m4_foreach([cflag],[
[-fbracket-depth=4096],
[-fcf-protection=none],
[-Xclang -fno-pch-timestamp],
[-mno-cet],
[-Qunused-arguments],
[-Wno-bool-operation],
@@ -478,6 +480,7 @@ m4_foreach([cflag],[
[-Wno-parentheses-equality],
[-Wno-shadow],
[-Wno-sign-compare],
[-Wno-subobject-linkage],
[-Wno-tautological-bitwise-compare],
[-Wno-tautological-compare],
[-Wno-uninitialized],
@@ -514,7 +517,7 @@ if test "$CFG_ENABLE_PARTIAL_STATIC" = "yes"; then
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -static-libgcc)
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -static-libstdc++)
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -Xlinker -gc-sections)
LTCMALLOC=-l:libtcmalloc_minimal.a
LTCMALLOC="-Wl,--whole-archive -l:libtcmalloc_minimal.a -Wl,--no-whole-archive"
else
LTCMALLOC=-ltcmalloc_minimal
fi
@@ -538,7 +541,7 @@ _MY_LDLIBS_CHECK_IFELSE(
[if test "$CFG_WITH_TCMALLOC" != "no"; then
CFG_LIBS="$LTCMALLOC $CFG_LIBS";
# If using tcmalloc, add some extra options to make the compiler not assume
# it is using it's own versions of the standard library functions
# it is using its own versions of the standard library functions
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-malloc)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-calloc)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-realloc)
+6 -6
View File
@@ -7,8 +7,8 @@ This contributing document contains some suggestions that may make
contributions flow more efficiently.
Did you find a bug?
-------------------
Did you find a Verilator bug?
-----------------------------
- Please **ensure the bug was not already reported** by searching
`Verilator Issues <https://verilator.org/issues>`__.
@@ -28,8 +28,8 @@ Did you find a bug?
<https://github.com/verilator/verilator/blob/master/docs/internals.rst>`__.
Did you write a patch that fixes a bug?
---------------------------------------
Did you write a patch that fixes a Verilator bug?
-------------------------------------------------
- Please `Open a new Verilator issue <https://verilator.org/issues/new>`__
if there is not one already describing the bug.
@@ -72,8 +72,8 @@ Did you write a patch that fixes a bug?
- Most important is we get your patch.
Do you have questions?
----------------------
Do you have questions on Verilator?
-----------------------------------
- Please see FAQ section and rest of the `Verilator
manual <https://verilator.org/verilator_doc.html>`__, or `Verilator
+16
View File
@@ -19,12 +19,14 @@ Andreas Kuster
Andrei Kostovski
Andrew Miloradovsky
Andrew Nolte
Andrew Voznytsa
Anthony Donlon
Anthony Moore
Arkadiusz Kozdra
Arthur Rosa
Aylon Chaim Porat
Bartłomiej Chmiel
Brian Li
Cameron Kirk
Chih-Mao Chen
Chris Bachhuber
@@ -38,9 +40,11 @@ Daniel Bates
David Horton
David Ledger
David Metz
Dave Sargeant
David Stanford
David Turner
Dercury
Diego Roux
Don Williamson
Drew Ranck
Drew Taussig
@@ -63,6 +67,7 @@ Garrett Smith
Geza Lore
Gianfranco Costamagna
Gijs Burghoorn
Gilberto Abram
Glen Gibb
Gökçe Aydos
Graham Rushton
@@ -99,11 +104,13 @@ Jesse Taube
Jevin Sweval
Jiacheng Qian
Jiamin Zhu
Jitesh Nayak
Jinyan Xu
Jiuyang Liu
Joey Liu
John Coiner
John Demme
John Khoo
John Wehle
Jonathan Drolet
Jonathan Schröter
@@ -129,6 +136,7 @@ Krzysztof Boronski
Krzysztof Boroński
Krzysztof Obłonczek
Krzysztof Starecki
Krzysztof Sychla
Kuba Ober
Larry Doolittle
Liam Braun
@@ -145,6 +153,7 @@ Marlon James
Marshal Qiao
Martin Schmidt
Martin Stadler
Mateusz Gancarz
Matthew Ballance
Michael Bikovitsky
Michael Killough
@@ -155,10 +164,13 @@ Miodrag Milanović
Mladen Slijepcevic
Morten Borup Petersen
Mostafa Gamal
Moubarak Jeje
Nandu Raj
Natan Kreimer
Nathan Graybeal
Nathan Kohagen
Nathan Myers
Nick Brereton
Nolan Poe
Oleh Maksymenko
Patrick Stewart
@@ -185,6 +197,7 @@ Ricardo Barbedo
Richard Myers
Risto Pejašinović
Robert Balas
Robin Heinemann
Rupert Swarbrick
Ryan Ziegler
Ryszard Rozak
@@ -210,6 +223,7 @@ Todd Strader
Tomasz Gorochowik
Topa Topino
Toru Niina
Trung Nguyen
Tudor Timi
Tymoteusz Blazejczyk
Udi Finkelstein
@@ -236,6 +250,8 @@ Yutetsu TAKATSUKASA
Yves Mathieu
Zhanglei Wang
Zhou Shen
Zhouyi Shen
Zixi Li
أحمد المحمودي
404allen404
Tobias Jensen
+1
View File
@@ -77,6 +77,7 @@ help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
clean mostlyclean distclean maintainer-clean::
rm -rf _build
rm -f $(SCRIPTS) *.tmp
rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log
rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs *.idx
+1 -9
View File
@@ -169,15 +169,7 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
# latex_documents = [
# (
# master_doc,
# "Verilog-to-Routing.tex",
# "Verilog-to-Routing Documentation",
# "VTR Developers",
# "manual",
# ),
# ]
# latex_documents = [ ... ]
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
+2 -2
View File
@@ -73,8 +73,8 @@ often inlined into the root scope) will need to be updated as follows:
:code:`$` character, i.e.: :code:`rootp` points to the Verilated
SystemVerilog :code:`$root` scope.
* Replace :code:`modelp->internal->member->lookup` references with
:code:`modelp->rootp->internal->member->lookup` references, which
* Replace :code:`modelp->internal->member` references with
:code:`modelp->rootp->internal->member` references, which
contain one additional indirection via the :code:`rootp` pointer.
+7 -3
View File
@@ -72,13 +72,17 @@ and the design can be easily manually reduced. In other cases, the bug is
caused by a complex interaction of many parts of the design, and it is not
clear which parts are necessary to reproduce the bug. In these cases, an
Open Source tool called `sv-bugpoint
<https://github.com/antmicro/sv-bugpoint>_` can be used to automatically
<https://github.com/antmicro/sv-bugpoint>`_ can be used to automatically
reduce a SystemVerilog design to the smallest possible reproducer.
It can be used to automatically reduce a design with hundreds of thousands of
lines to a minimal test case while preserving the bug-inducing behavior.
Please refer to the `README
<https://github.com/antmicro/sv-bugpoint/blob/main/README.md>`_ file for more
With :vlopt:`--debug`, Verilator will write a *{prefix}*\ __inputs\ .vpp
file which has all of the individual input files combined and
pre-processed, this is often useful as the input design into `sv-bugpoint`.
Please refer to `sv-bugpoint README
<https://github.com/antmicro/sv-bugpoint/blob/main/README.md>`_ for more
information on how to use `sv-bugpoint`.
.. Contributing
+5 -5
View File
@@ -47,6 +47,11 @@ Summary:
Display help and exit.
.. option:: +verilator+noassert
Disable assert checking per runtime argument. This is the same as
calling :code:`VerilatedContext*->assertOn(false)` in the model.
.. option:: +verilator+prof+exec+file+<filename>
When a model was Verilated using :vlopt:`--prof-exec`, sets the
@@ -110,11 +115,6 @@ Summary:
simulation runtime random seed value. If zero or not specified picks a
value from the system random number generator.
.. option:: +verilator+noassert
Disable assert checking per runtime argument. This is the same as
calling :code:`VerilatedContext*->assertOn(false)` in the model.
.. option:: +verilator+V
Shows the verbose version, including configuration information.
File diff suppressed because it is too large Load Diff
+73 -70
View File
@@ -49,116 +49,119 @@ verilator_coverage Arguments
.. option:: <filename>
Specifies the input coverage data file. Multiple filenames may be provided
to read multiple inputs. If no data file is specified, by default,
"coverage.dat" will be read.
Specifies the input coverage data file. Multiple filenames may be
provided to read multiple inputs. If no data file is specified, by
default, "coverage.dat" will be read.
.. option:: --annotate <output_directory>
Specifies the directory name to which source files with annotated coverage
data should be written.
Specifies the directory name to which source files with annotated
coverage data should be written.
Points are children of each line coverage- branches or toggle points.
When point counts are aggregated into a line, the minimum and maximum counts
are used to determine the status of the line (complete, partial, failing)
The count is equal to the maximum of the points.
Points are children of each line coverage- branches, expressions or
toggle points. When point counts are aggregated into a line, the
minimum and maximum counts are used to determine the status of the line
(complete, partial, failing) The count is equal to the maximum of the
points.
Coverage data is annotated at the beginning of the line and is formatted
as a special character followed by the number of coverage hits. The special
characters " ,%,~,+,-" indicate summary of the coverage, and allow use of grep
to filter the report.
Coverage data is annotated at the beginning of the line and is formatted
as a special character followed by the number of coverage hits. The
special characters " ,%,~,+,-" indicate summary of the coverage, and
allow use of grep to filter the report.
* " " (whitespace) indicates that all points on the line are above the coverage min.
* "%" indicates that all points on the line are below the coverage min.
* "~" indicates that some points on the line are above the coverage min and some are below.
* "+" coverage point was at or above the min. Only used with :option:`--annotate-points`.
* "-" coverage point was below the min. Only used with :option:`--annotate-points`.
* " " (whitespace) indicates that all points on the line are above the coverage min.
* "%" indicates that all points on the line are below the coverage min.
* "~" indicates that some points on the line are above the coverage min and some are below.
* "+" coverage point was at or above the min. Only used with :option:`--annotate-points`.
* "-" coverage point was below the min. Only used with :option:`--annotate-points`.
.. code-block::
.. code-block::
100000 input logic a; // Begins with whitespace, because
// number of hits (100000) is above the min.
+100000 point: comment=a // Begins with +, because
// number of hits (100000) is above the min.
%000000 input logic b; // Begins with %, because
// number of hits (0) is below the min.
-000000 point: comment=b // Begins with -, because
// number of hits (0) is below the min.
~000010 if (cyc!=0) begin // Begins with ~, because
// branches are below and above the min.
+000010 point: comment=if // The if branch is above the min.
-000000 point: comment=else // The else branch is below the min.
100000 input logic a; // Begins with whitespace, because
// number of hits (100000) is above the min.
+100000 point: comment=a // Begins with +, because
// number of hits (100000) is above the min.
%000000 input logic b; // Begins with %, because
// number of hits (0) is below the min.
-000000 point: comment=b // Begins with -, because
// number of hits (0) is below the min.
~000010 if (cyc!=0) begin // Begins with ~, because
// branches are below and above the min.
+000010 point: comment=if // The if branch is above the min.
-000000 point: comment=else // The else branch is below the min.
.. option:: --annotate-all
Specifies all files should be shown. By default, only those source files
with low coverage are written to the output directory.
Specifies all files should be shown. By default, only those source
files with low coverage are written to the output directory.
This option should be used together with :option:`--annotate`.
This option should be used together with :option:`--annotate`.
.. option:: --annotate-min <count>
Specifies the threshold (<count>) below which coverage point is considered
sufficient. If the threshold is not exceeded, then the annotation will begin
with a "%" symbol to indicate the coverage is insufficient.
Specifies the threshold (<count>) below which coverage point is
considered sufficient. If the threshold is not exceeded, then the
annotation will begin with a "%" symbol to indicate the coverage is
insufficient.
The <count> threshold defaults to 10.
The <count> threshold defaults to 10.
This option should be used together with :option:`--annotate`.
This option should be used together with :option:`--annotate`.
.. option:: --annotate-points
Specifies all coverage points should be shown after each line of text. By
default, only source lines are shown.
Specifies all coverage points should be shown after each line of text. By
default, only source lines are shown.
.. code-block::
.. code-block::
100000 input logic a, b, c;
+100000 point: comment=a // These lines are only shown
+200000 point: comment=b // with option --annotate-points
+300000 point: comment=c // enabled.
100000 input logic a, b, c;
+100000 point: comment=a // These lines are only shown
+200000 point: comment=b // with option --annotate-points
+300000 point: comment=c // enabled.
This option should be used together with :option:`--annotate`.
This option should be used together with :option:`--annotate`.
.. option:: --help
Displays a help summary, the program version, and exits.
Displays a help summary, the program version, and exits.
.. option:: --rank
Prints an experimental report listing the relative importance of each test
in covering all of the coverage points. The report shows "Covered" which
indicates the number of points the test covers; a test is considered to
cover a point if it has a bucket count of at least 1. The "rank" column has
a higher number t indicate the test is more critical, and rank 0 means the
test does not need to be run to cover the points. "RankPts" indicates the
number of coverage points this test will contribute to overall coverage if
all tests are run in the order of highest to the lowest rank.
Prints an experimental report listing the relative importance of each
test in covering all of the coverage points. The report shows "Covered"
which indicates the number of points the test covers; a test is
considered to cover a point if it has a bucket count of at least 1. The
"rank" column has a higher number t indicate the test is more critical,
and rank 0 means the test does not need to be run to cover the points.
"RankPts" indicates the number of coverage points this test will
contribute to overall coverage if all tests are run in the order of
highest to the lowest rank.
.. option:: --unlink
With :option:`--write`, unlink all input files after the output
has been successfully created.
With :option:`--write`, unlink all input files after the output has been
successfully created.
.. option:: --version
Displays program version and exits.
Displays program version and exits.
.. option:: --write <filename>
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename in verilator_coverage data format.
This is useful in scripts to combine many coverage data files (likely
generated from random test runs) into one master coverage file.
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename in verilator_coverage data
format. This is useful in scripts to combine many coverage data files
(likely generated from random test runs) into one master coverage file.
.. option:: --write-info <filename.info>
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename in :command:`lcov` .info format.
This may be used to feed into :command:`lcov` to aggregate or generate
reports. This format lacks the comments for cover points that the
verilator_coverage format has. It can be used with :command:`genhtml`
to generate an HTML report. :command:`genhtml --branch-coverage` will
also display the branch coverage, analogous to :option:`--annotate-points`
Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename in :command:`lcov` .info format.
This may be used to feed into :command:`lcov` to aggregate or generate
reports. This format lacks the comments for cover points that the
verilator_coverage format has. It can be used with :command:`genhtml` to
generate an HTML report. :command:`genhtml --branch-coverage` will also
display the branch coverage, analogous to :option:`--annotate-points`.
+8 -4
View File
@@ -51,6 +51,10 @@ predicted_parallelism
cpu#_thread
For the given CPU number, the thread number measured to be executing.
cpu#_waiting
For the given CPU number, aggregated waiting time for mtask dependencies.
Visualized as `X` values.
mtask#_cpu
For the given mtask id, the CPU it was measured to execute on.
@@ -80,16 +84,16 @@ verilator_gantt Arguments
.. option:: <filename>
The filename to read data from; the default is "profile_exec.dat".
The filename to read data from; the default is "profile_exec.dat".
.. option:: --help
Displays a help summary, the program version, and exits.
Displays a help summary, the program version, and exits.
.. option:: --no-vcd
Disables creating a .vcd file.
Disables creating a .vcd file.
.. option:: --vcd <filename>
Sets the output filename for vcd dump; the default is "verilator_gantt.vcd".
Sets the output filename for vcd dump; the default is "verilator_gantt.vcd".
+2 -2
View File
@@ -33,8 +33,8 @@ verilator_profcfunc Arguments
.. option:: <filename>
The :command:`gprof`-generated filename to read data from. Typically "gprof.out".
The :command:`gprof`-generated filename to read data from. Typically "gprof.out".
.. option:: --help
Displays a help summary, the program version, and exits.
Displays a help summary, the program version, and exits.
+207 -165
View File
@@ -1,14 +1,19 @@
.. Copyright 2003-2025 by Wilson Snyder.
.. SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
*******************
Language Extensions
*******************
=====================
Language Extensions
=====================
The following additional constructs are the extensions Verilator supports
on top of standard Verilog code. Using these features outside of comments
or "`ifdef`"'s may break other tools.
.. option:: """ [string] """
A triple-quoted block specifies a string that may include newlines and
single quotes. This extension was standardized in IEEE 1800-2023.
.. option:: `__FILE__
The :option:`\`__FILE__` define expands to the current filename as a
@@ -21,6 +26,12 @@ or "`ifdef`"'s may break other tools.
C++'s __LINE__. This Verilator feature added in 2006 was incorporated
into IEEE 1800-2009.
.. option:: `coverage_block_off
Specifies the entire begin/end block should be ignored for coverage
analysis. Must be inside a code block, e.g., within a begin/end pair.
Same as :option:`coverage_block_off` in :ref:`Configuration Files`.
.. option:: `error [string]
This will report an error when the preprocessor emits it, similar to
@@ -33,10 +44,116 @@ or "`ifdef`"'s may break other tools.
internal tests, so that debugging can leave the line numbers correctly
referring to the test file's line numbers.
.. option:: """ [string] """
.. option:: `systemc_class_name
A triple-quoted block specifies a string that may include newlines and
single quotes. This extension was standardized in IEEE 1800-2023.
Inside one of the :option:`\`systemc_... <\`systemc_header>` text
blocks, replaced with the C++ class name generated for the given
containing SystemVerilog class or module. Currently this is replaced
blindly, ignoring quoting or other escapes; this behavior may change in
the future. This attribute is indented only to be used internally in
`verilated_std.sv`.
.. option:: `systemc_ctor
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class constructor. Must be placed as a module or
class item, e.g., directly inside a module/endmodule or class/endclass
pair. Despite the name of this macro, this also works in pure C++ code.
.. option:: `systemc_dtor
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class destructor. Must be placed as a module or
class item, e.g., directly inside a module/endmodule or class/endclass
pair. Despite the name of this macro, this also works in pure C++ code.
.. option:: `systemc_header
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the output .h file's header. Must be placed as a module
or class item, e.g., directly inside a module/endmodule or
class/endclass pair. Despite the name of this macro, this also works in
pure C++ code.
.. option:: `systemc_header_post
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the output .h file's header after the class definition.
Must be placed as a module or class item, e.g., directly inside a
module/endmodule or class/endclass pair. Despite the name of this macro,
this also works in pure C++ code.
.. option:: `systemc_imp_header
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the header of all files for this C++ class implementation.
Must be placed as a module or class item, e.g., directly inside a
module/endmodule or class/endclass pair. Despite the name of this macro,
this also works in pure C++ code.
.. option:: `systemc_implementation
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into a single file of the C++ class implementation. Must be
placed as a module or class item, e.g., directly inside a
module/endmodule or class/endclass pair. Despite the name of this macro,
this also works in pure C++ code.
If you will be reading or writing any Verilog variables in the C++
functions, the Verilog signals must be declared with a
:option:`/*verilator&32;public*/` metacomment. See also the public task
feature; writing an accessor may result in cleaner code.
.. option:: `systemc_interface
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class interface. Must be placed as a module or
class item, e.g., directly inside a module/endmodule or class/endclass
pair. Despite the name of this macro, this also works in pure C++ code.
.. option:: `SYSTEMVERILOG
The SYSTEMVERILOG, SV_COV_START, and related standard predefined macros
are defined by default when :vlopt:`--language <--language>` is
"1800-\*".
.. option:: `VERILATOR
.. option:: `verilator
.. option:: `verilator3
The VERILATOR, verilator and verilator3 predefined macros are defined by
default so you may "\`ifdef" around tool specific constructs.
.. option:: `verilator_config
Take the remaining text up to the next :option:`\`verilog` mode switch and
treat it as Verilator configuration commands. See :ref:`Configuration Files`.
.. option:: `VERILATOR_TIMING
The VERILATOR_TIMING define is set when :vlopt:`--timing` is used to
allow an "\`ifdef" of code dependent on this feature. Note that this define
is not affected by the :option:`timing_off` configuration file option
nor timing metacomments.
.. option:: `verilog
Switch back to processing Verilog code after a
:option:`\`systemc_... <\`systemc_header>` mode switch. The Verilog
code returns to the last language mode specified with
"\`begin_keywords", or SystemVerilog if none was specified.
.. t_dist_docs_style restart_sort
.. option:: $c([string], ...);
@@ -86,6 +203,16 @@ or "`ifdef`"'s may break other tools.
prints 5 digits per the C standard. This extension was standardized into
1800-2009.
.. option:: $stacktrace
Called as a task, print a stack trace. Called as a function, return a
string with a stack trace. This relies on the C++ system trace, which
may give less meaningful results if the model is not compiled with debug
symbols. Also, the data represents the C++ stack; the SystemVerilog
functions/tasks involved may be renamed and/or inlined before becoming
the C++ functions that may be visible in the stack trace. This
extension was standardized in IEEE 1800-2023.
.. option:: $timeprecision
Returns the timeprecision of the model as an integer. This extension is
@@ -96,98 +223,6 @@ or "`ifdef`"'s may break other tools.
Returns the timeunit of the current module as an integer. This
extension is experimental and may be removed without deprecation.
.. option:: `coverage_block_off
Specifies the entire begin/end block should be ignored for coverage
analysis. Must be inside a code block, e.g., within a begin/end pair.
Same as :option:`coverage_block_off` in :ref:`Configuration Files`.
.. option:: `systemc_header
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the output .h file's header. Must be placed as a module
item, e.g., directly inside a module/endmodule pair. Despite the name of
this macro, this also works in pure C++ code.
.. option:: `systemc_ctor
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class constructor. Must be placed as a module
item, e.g., directly inside a module/endmodule pair. Despite the name of
this macro, this also works in pure C++ code.
.. option:: `systemc_dtor
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class destructor. Must be placed as a module
item, e.g., directly inside a module/endmodule pair. Despite the name of
this macro, this also works in pure C++ code.
.. option:: `systemc_interface
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the C++ class interface. Must be placed as a module item,
e.g., directly inside a module/endmodule pair. Despite the name of this
macro, this also works in pure C++ code.
.. option:: `systemc_imp_header
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into the header of all files for this C++ class implementation.
Must be placed as a module item, e.g., directly inside a module/endmodule
pair. Despite the name of this macro, this also works in pure C++ code.
.. option:: `systemc_implementation
Take the remaining text up to the next :option:`\`verilog` or
:option:`\`systemc_... <\`systemc_header>` mode switch and place it
verbatim into a single file of the C++ class implementation. Must be
placed as a module item, e.g., directly inside a module/endmodule
pair. Despite the name of this macro, this also works in pure C++ code.
If you will be reading or writing any Verilog variables in the C++
functions, the Verilog signals must be declared with a
:option:`/*verilator&32;public*/` metacomment. See also the public task
feature; writing an accessor may result in cleaner code.
.. option:: `SYSTEMVERILOG
The SYSTEMVERILOG, SV_COV_START, and related standard defines are set by
default when :vlopt:`--language <--language>` is "1800-\*".
.. option:: `VERILATOR
.. option:: `verilator
.. option:: `verilator3
The VERILATOR, verilator and verilator3 defines are set by default so
you may "\`ifdef" around tool specific constructs.
.. option:: `verilator_config
Take the remaining text up to the next :option:`\`verilog` mode switch and
treat it as Verilator configuration commands. See :ref:`Configuration Files`.
.. option:: `VERILATOR_TIMING
The VERILATOR_TIMING define is set when :vlopt:`--timing` is used to
allow an "\`ifdef" of code dependent on this feature. Note that this define
is not affected by the :option:`timing_off` configuration file option
nor timing metacomments.
.. option:: `verilog
Switch back to processing Verilog code after a
:option:`\`systemc_... <\`systemc_header>` mode switch. The Verilog
code returns to the last language mode specified with
"\`begin_keywords", or SystemVerilog if none was specified.
.. option:: /*verilator&32;clock_enable*/
Deprecated and has no effect (ignored).
@@ -212,6 +247,9 @@ or "`ifdef`"'s may break other tools.
Same as :option:`clock_enable` configuration file option.
.. t_dist_docs_style ignore /*verilator&32;no_clocker*/
.. option:: /*verilator&32;clocker*/
.. option:: /*verilator&32;no_clocker*/
@@ -379,29 +417,6 @@ or "`ifdef`"'s may break other tools.
parameter [2:0] PARAM /*verilator public*/ = 2'b0;
.. option:: /*verilator&32;public*/ (on typedef enum)
Used after an enum typedef declaration to indicate the emitted C code
should have the enum values visible. Due to C++ language restrictions,
this may only be used on 64-bit or narrower integral enumerations.
.. code-block:: sv
typedef enum logic [2:0] { ZERO = 3'b0 } pub_t /*verilator public*/;
.. option:: /*verilator&32;public*/ (on variable)
Used after an input, output, register, or wire declaration to indicate
the signal should be declared so that C code may read or write the value
of the signal. This will also declare this module public; otherwise, use
:code:`/*verilator&32;public_flat*/`.
Instead of using public variables, consider making a DPI or public
function that accesses the variable. This is nicer as it provides an
obvious entry point compatible across simulators.
Same as :option:`public` configuration file option.
.. option:: /*verilator&32;public*/ (on task/function)
Used inside the declaration section of a function or task declaration to
@@ -426,6 +441,52 @@ or "`ifdef`"'s may break other tools.
Same as :option:`public` configuration file option.
.. option:: /*verilator&32;public*/ (on typedef enum)
Used after an enum typedef declaration to indicate the emitted C code
should have the enum values visible. Due to C++ language restrictions,
this may only be used on 64-bit or narrower integral enumerations.
.. code-block:: sv
typedef enum logic [2:0] { ZERO = 3'b0 } pub_t /*verilator public*/;
.. option:: /*verilator&32;public*/ (on variable)
Used after an input, output, register, or wire declaration to indicate
the signal should be declared so that C code may read or write the value
of the signal. This will also declare this module public; otherwise, use
:code:`/*verilator&32;public_flat*/`.
Instead of using public variables, consider making a DPI or public
function that accesses the variable. This is nicer as it provides an
obvious entry point compatible across simulators.
Same as :option:`public` configuration file option.
.. option:: /*verilator&32;public_[|flat|flat_rd|flat_rw]_on [@(<edge_list>)]*/ (as scope)
Used to wrap multiple signals and parameters with the respective public attribute.
See attribute above for their respective behavior. Cannot be nested. e.g:
.. code-block:: sv
/*verilator public_flat_rw_on*/
logic clk;
logic rst;
parameter width = 8;
/* verilator public_off*/
logic data;
Is equivalent to:
.. code-block:: sv
logic clk /*verilator public_flat_rw*/;
logic rst /*verilator public_flat_rw*/;
parameter width /*verilator public_flat_rw*/ = 8;
logic data;
.. option:: /*verilator&32;public_flat*/ (on variable)
Used after an input, output, register, or wire declaration to indicate
@@ -453,33 +514,6 @@ or "`ifdef`"'s may break other tools.
Same as :option:`public_flat_rw` configuration file option.
.. option:: /*verilator&32;public_[|flat|flat_rd|flat_rw]_on [@(<edge_list>)]*/ (as scope)
Used to wrap multiple signals and parameters with the respective public attribute.
See attribute above for their respective behavior. Cannot be nested. e.g:
.. code-block:: sv
/*verilator public_flat_rw_on*/
logic clk;
logic rst;
parameter width = 8;
/* verilator public_off*/
logic data;
Is equivalent to:
.. code-block:: sv
logic clk /*verilator public_flat_rw*/;
logic rst /*verilator public_flat_rw*/;
parameter width /*verilator public_flat_rw*/ = 8;
logic data;
.. option:: /*verilator&32;public_off*/
Terminates the previous `/*verilator public*_on*/` directive; see above.
.. option:: /*verilator&32;public_module*/
Used after a module statement to indicate the module should not be
@@ -490,13 +524,9 @@ or "`ifdef`"'s may break other tools.
Same as :option:`public` configuration file option.
.. option:: /*verilator&32;sc_clock*/
.. option:: /*verilator&32;public_off*/
Deprecated and ignored. Previously used after an input declaration to
indicate the signal should be declared in SystemC as a sc_clock instead
of a bool. This was needed in SystemC 1.1 and 1.2 only; versions 2.0
and later do not require clock pins to be sc_clocks, and this is no
longer needed and is ignored.
Terminates the previous `/*verilator public*_on*/` directive; see above.
.. option:: /*verilator&32;sc_bv*/
@@ -509,6 +539,14 @@ or "`ifdef`"'s may break other tools.
Same as :option:`sc_bv` configuration file option.
.. option:: /*verilator&32;sc_clock*/
Deprecated and ignored. Previously used after an input declaration to
indicate the signal should be declared in SystemC as a sc_clock instead
of a bool. This was needed in SystemC 1.1 and 1.2 only; versions 2.0
and later do not require clock pins to be sc_clocks, and this is no
longer needed and is ignored.
.. option:: /*verilator&32;sformat*/
Attached to the final argument of type "input string" of a function or
@@ -550,6 +588,20 @@ or "`ifdef`"'s may break other tools.
large arrays may slow down the Verilation speed, so use this only on
variables that require it.
Packed variables that are only referenced locally (without hierarchical
references) via non-overlapping, constant-indexed bit or part select
expressions are split automatically. This covers the somewhat common
usage pattern:
.. code-block:: sv
logic [1:0][31:0] tmp;
assign tmp[0] = foo + a;
assign tmp[1] = tmp[1] + b;
assign bar = tmp[1] + c;
Same as :option:`split_var` configuration file option.
.. option:: /*verilator&32;tag <text...>*/
@@ -583,7 +635,7 @@ or "`ifdef`"'s may break other tools.
Attached to a DPI import to indicate that function should be called when
initializing tracing. This attribute is indented only to be used
internally in code that Verilator generates when :vlopt:`--lib-create`
or :vlopt:`--hierarchical` is used along with :vlopt:`--trace`.
or :vlopt:`--hierarchical` is used along with :vlopt:`--trace-vcd`.
.. option:: /*verilator&32;tracing_off*/
@@ -613,13 +665,3 @@ or "`ifdef`"'s may break other tools.
following loop at the same statement level should always be fully
unrolled by Verilator, ignoring :vlopt:`--unroll-count`. This is
similar to clang's ``#pragma clang loop unroll(full)``.
.. option:: $stacktrace
Called as a task, print a stack trace. Called as a function, return a
string with a stack trace. This relies on the C++ system trace, which
may give less meaningful results if the model is not compiled with debug
symbols. Also, the data represents the C++ stack; the SystemVerilog
functions/tasks involved may be renamed and/or inlined before becoming
the C++ functions that may be visible in the stack trace. This
extension was standardized in IEEE 1800-2023.
+2 -2
View File
@@ -128,7 +128,7 @@ How do I generate waveforms (traces) in C++?
See also the next question for tracing in SystemC mode.
A. Pass the :vlopt:`--trace` option to Verilator. Then you may use ``$dumpfile`` and
A. Pass the :vlopt:`--trace-vcd` option to Verilator. Then you may use ``$dumpfile`` and
``$dumpvars`` to enable traces, the same as with any Verilog simulator,
although Verilator ignores the arguments to ``$dumpvars``. See
``examples/make_tracing_c`` in the distribution.
@@ -177,7 +177,7 @@ file.
How do I generate waveforms (traces) in SystemC?
""""""""""""""""""""""""""""""""""""""""""""""""
A. Pass the :vlopt:`--trace` option to Verilator, and in your top-level
A. Pass the :vlopt:`--trace-vcd` option to Verilator, and in your top-level
:code:`sc_main()`, call :code:`Verilated::traceEverOn(true)`. Then you
may use :code:`$dumpfile` and code:`$dumpvars` to enable traces, as
with any Verilog simulator; see the non-SystemC example in
+2 -2
View File
@@ -65,9 +65,9 @@ For --cc/--sc, it creates:
* - *{prefix}*\ ___024root\ *{__DepSet_hash__n}*\ .cpp
- Infrequent cold routines (hashed to reduce build times)
* - *{prefix}*\ ___024root__Trace\ *{__n}*\ .cpp
- Wave file generation code (from --trace)
- Wave file generation code (from --trace-\*)
* - *{prefix}*\ ___024root__Trace__Slow\ *{__n}*\ .cpp
- Wave file generation code (from --trace)
- Wave file generation code (from --trace-\*)
* - *{prefix}*\ __Dpi.h
- DPI import and export declarations (from --dpi)
* - *{prefix}*\ __Dpi.cpp
+31 -12
View File
@@ -15,9 +15,9 @@ Package Manager Quick Install
=============================
Using a distribution's package manager is the easiest way to get
started. (Note packages are unlikely to have the most recent version, so
:ref:`Git Install` might be a better alternative.) To install as a
package:
started. (Note distribution packages almost never have the most recent
Verilator version, so we recommend following :ref:`Git Install` below,
instead.) To install as a package:
.. code-block:: shell
@@ -118,6 +118,25 @@ To build or run Verilator, you need these standard packages:
sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error)
For SystemC:
.. code-block:: shell
sudo apt-get install libsystemc libsystemc-dev
For constraints:
.. code-block:: shell
sudo apt-get install z3 # Optional solver
The following is optional but is recommended for nicely rendered command line
help when running Verilator:
.. code-block:: shell
sudo apt-get install perl-doc
To build or run Verilator, the following are optional but should be installed
for good performance:
@@ -127,13 +146,6 @@ for good performance:
sudo apt-get install mold # If present at build, needed for run
sudo apt-get install libgoogle-perftools-dev numactl
The following is optional but is recommended for nicely rendered command line
help when running Verilator:
.. code-block:: shell
sudo apt-get install perl-doc
To build Verilator you will need to install these packages; these do not
need to be present to run Verilator:
@@ -146,7 +158,7 @@ Those developing Verilator itself may also want these (see internals.rst):
.. code-block:: shell
sudo apt-get install clang clang-format-14 cmake gdb gprof graphviz lcov
sudo apt-get install python3-clang yapf3 bear jq
sudo apt-get install python3-clang python3-distro yapf3 bear jq
sudo pip3 install sphinx sphinx_rtd_theme sphinxcontrib-spelling breathe ruff
sudo pip3 install git+https://github.com/antmicro/astsee.git
cpan install Pod::Perldoc
@@ -155,7 +167,10 @@ Those developing Verilator itself may also want these (see internals.rst):
Install SystemC
^^^^^^^^^^^^^^^
If you will be using SystemC (vs straight C++ output), download `SystemC
SystemC code can be generated from Verilator (with :vlopt:`--sc`) if it is
installed as a package (see above).
Alternatively, from their sources, download `SystemC
<https://www.accellera.org/downloads/standards/systemc>`__. Follow their
installation instructions. You will need to set the
:option:`SYSTEMC_INCLUDE` environment variable to point to the include
@@ -170,6 +185,10 @@ To make use of Verilator FST tracing you will want `GTKwave
<http://gtkwave.sourceforge.net/>`__ installed, however this is not
required at Verilator build time.
.. code-block:: shell
sudo apt-get install gtkwave # Optional Waveform viewer
Install Z3
^^^^^^^^^^
+16 -15
View File
@@ -334,7 +334,8 @@ Gate Primitives
The 2-state gate primitives (and, buf, nand, nor, not, or, xnor, xor) are
directly converted to behavioral equivalents. The 3-state and MOS gate
primitives are not supported. Tables are not supported.
primitives are not supported. User-defined primitive (UDP) tables are
supported.
Specify blocks
@@ -396,8 +397,8 @@ This section describes specific limitations for each language keyword.
\`begin_keywords, \`begin_keywords, \`begin_keywords, \`begin_keywords,
\`define, \`else, \`elsif, \`end_keywords, \`endif, \`error, \`ifdef,
\`ifndef, \`include, \`line, \`systemc_ctor, \`systemc_dtor,
\`systemc_header, \`systemc_imp_header, \`systemc_implementation,
\`systemc_interface, \`undef, \`verilog
\`systemc_header, \`systemc_header_post, \`systemc_imp_header,
\`systemc_implementation, \`systemc_interface, \`undef, \`verilog
|cmdslong1|
Fully supported.
@@ -451,17 +452,17 @@ disable
force, release
Verilator supports the procedural `force` (and corresponding `release`)
statement. However, the behavior of the `force` statement does not
entirely comply with IEEE 1800. According to the standard, when a
procedural statement of the form `force a = b;` is executed, the
simulation should behave as if, from that point forwards, a continuous
assignment `assign a = b;` has been added to override the drivers of `a`.
More specifically: the value of `a` should be updated whenever the value
of `b` changes, until a `release a;` statement is executed. Verilator
instead evaluates the current value of `b` when the `force` statement is
executed, and forces `a` to that value, without updating it until a new
`force` or `release` statement is encountered that applies to `a`. This
non-standard behavior is nevertheless consistent with some other
simulators.
entirely comply with IEEE 1800-2023:
#. Using forced variable as a value to another force statement is
currently not supported. The dependent force statement is forced by an
initial constant value.
#. Force/release with procedural continuous assignment is not supported.
The assignment is treated as procedural.
#. Expressions using multiple variable references or function calls on
forced right-hand side are not sensitive to dependency changes.
inside
Inside expressions may not include unpacked array traversal or $ as an
@@ -488,7 +489,7 @@ $bits, $countbits, $countones, $finish, $isunknown, $onehot, $onehot0, $signed,
$dump/$dumpports and related
$dumpfile or $dumpports will create a VCD or FST file (based on
the :vlopt:`--trace` option given when the model was Verilated). This
the :vlopt:`--trace-vcd` option given when the model was Verilated). This
will take effect starting at the next eval() call. If you have multiple
Verilated designs under the same C model, this will dump signals
only from the design containing the $dumpvars.
+40 -3
View File
@@ -83,9 +83,10 @@ option will require a longer time to run Verilator, and
may increase the risk of reset bugs in trade for performance; see the above
documentation for these options.
If using Verilated multithreaded, use ``numactl`` to ensure you use
non-conflicting hardware resources. See :ref:`Multithreading`. Also,
consider using profile-guided optimization; see :ref:`Thread PGO`.
If using Verilated multithreaded, consider overriding Verilator's default
thread-to-processor assignment by using ``numactl``; see
:ref:`Multithreading`. Also, consider using profile-guided optimization;
see :ref:`Thread PGO`.
Minor Verilog code changes can also give big wins. You should not have any
:option:`UNOPTFLAT` warnings from Verilator. Fixing these warnings can
@@ -270,6 +271,42 @@ A :option:`/*verilator&32;coverage_off*/`
signals that do not need toggle analysis, such as RAMs and register files.
.. _Expression Coverage:
Expression Coverage
-------------------
With :vlopt:`--coverage` or :vlopt:`--coverage-expr`, Verilator will
automatically add coverage analysis at each expression, indicating with a
truth table how every Boolean truth-table possibility in the expression
occurred.
Multi-bit expressions are ignored, but sub-expressions with are entirely
Boolean are analyzed. Expression coverage does not fully explore the truth
table of an expression, rather is looks at each term's contribution. E.g.
an AND operation will check coverage for TT, XF and FX.
Some expressions may produce too many cover points. Verilator limits the
maximum number of cover points per expression to 32, but this may be
controlled with :vlopt:`--coverage-expr-max`.
Below is an example showing expression coverage produced from `verilator_coverage`
as applied to the condition expression inside an if statement. Each line
shows the minimum number of terms and their values (e.g. `(t1==0 && t2==1)`) needed
to reach a result for the overall expression (e.g. `=> 1`). Each line also
shows the number of times this combination was hit. Note that individual lines
are not mutually exclusive.
.. code-block::
%000004 if ((~t1 && t2) || (~t3 && t4)) $write("");
-000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t
-000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t
-000004 point: comment=(t1==1 && t4==0) => 0 hier=top.t
-000002 point: comment=(t2==0 && t3==1) => 0 hier=top.t
-000003 point: comment=(t2==0 && t4==0) => 0 hier=top.t
-000002 point: comment=(t3==0 && t4==1) => 1 hier=top.t
.. _Suppressing Coverage:
Suppressing Coverage
+29 -16
View File
@@ -221,7 +221,7 @@ model, it may be beneficial to performance to adjust the
influences the partitioning of the model by adjusting the assumed execution
time of DPI imports.
When using :vlopt:`--trace` to perform VCD tracing, the VCD trace
When using :vlopt:`--trace-vcd` to perform VCD tracing, the VCD trace
construction is parallelized using the same number of threads as specified
with :vlopt:`--threads`, and is executed on the same thread pool as the model.
@@ -243,11 +243,14 @@ trace. FST tracing can utilize up to 2 offload threads, so there is no use
of setting :vlopt:`--trace-threads` higher than 2 at the moment.
When running a multithreaded model, the default Linux task scheduler often
works against the model by assuming short-lived threads and thus
it often schedules threads using multiple hyperthreads within the same
physical core. For best performance, use the :command:`numactl` program to
(when the threading count fits) select unique physical cores on the same
socket. The same applies for :vlopt:`--trace-threads` as well.
works against the model by assuming short-lived threads and thus it often
schedules threads using multiple hyperthreads within the same physical
core. If there is no affinity already set, on Linux only, Verilator
attempts to set thread-to-processor affinity in a reasonable way.
For best performance, use the :command:`numactl` program to (when the
threading count fits) select unique physical cores on the same socket. The
same applies for :vlopt:`--trace-threads` as well.
As an example, if a model was Verilated with
:vlopt:`--threads 4 <--threads>`, we consult:
@@ -290,8 +293,8 @@ and must be called only by the eval thread.
If using :vlopt:`--sc`, the SystemC kernel is not thread-safe; therefore,
the eval thread and main thread must be the same.
If using :vlopt:`--trace`, the tracing classes must be constructed and
called from the main thread.
If using :vlopt:`--trace-vcd` or other trace options, the tracing classes
must be constructed and called from the main thread.
If using :vlopt:`--vpi`, since SystemVerilog VPI was not architected by
IEEE to be multithreaded, Verilator requires all VPI calls are only made
@@ -367,10 +370,11 @@ Verilate in CMake
.. code-block:: CMake
verilate(target SOURCES source ... [TOP_MODULE top] [PREFIX name]
[TRACE] [TRACE_FST] [SYSTEMC] [COVERAGE]
[COVERAGE] [SYSTEMC]
[TRACE_FST] [TRACE_SAIF] [TRACE_VCD] [TRACE_THREADS num]
[INCLUDE_DIRS dir ...] [OPT_SLOW ...] [OPT_FAST ...]
[OPT_GLOBAL ..] [DIRECTORY dir] [THREADS num]
[TRACE_THREADS num] [VERILATOR_ARGS ...])
[VERILATOR_ARGS ...])
Lowercase and ... should be replaced with arguments; the uppercase parts
delimit the arguments and can be passed in any order or left out entirely
@@ -443,10 +447,6 @@ SystemC include directories and link to the SystemC libraries.
Optional. Enable a multithreaded model; see :vlopt:`--threads`.
.. describe:: TRACE_THREADS
Optional. Enable multithreaded FST trace; see :vlopt:`--trace-threads`.
.. describe:: TOP_MODULE
Optional. Sets the name of the top module. Defaults to the name of the
@@ -454,14 +454,27 @@ SystemC include directories and link to the SystemC libraries.
.. describe:: TRACE
Optional. Enables VCD tracing if present, equivalent to "VERILATOR_ARGS
--trace".
Deprecated. Same as TRACE_VCD, which should be used instead.
.. describe:: TRACE_FST
Optional. Enables FST tracing if present, equivalent to "VERILATOR_ARGS
--trace-fst".
.. describe:: TRACE_SAIF
Optional. Enables SAIF tracing if present, equivalent to "VERILATOR_ARGS
--trace-saif".
.. describe:: TRACE_THREADS
Optional. Enable multithreaded FST trace; see :vlopt:`--trace-threads`.
.. describe:: TRACE_VCD
Optional. Enables VCD tracing if present, equivalent to "VERILATOR_ARGS
--trace-vcd".
.. describe:: VERILATOR_ARGS
Optional. Extra arguments to Verilator. Do not specify :vlopt:`--Mdir`
+88 -48
View File
@@ -1,9 +1,9 @@
.. Copyright 2003-2025 by Wilson Snyder.
.. SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
*******************
Errors and Warnings
*******************
=====================
Errors and Warnings
=====================
.. _Disabling Warnings:
@@ -44,7 +44,7 @@ Warnings may be disabled in multiple ways:
.. code-block:: sv
lint_off -rule UNSIGNED -file "*/example.v" -line 1
lint_off -rule UNSIGNED -file "*/example.v" -lines 1
Error And Warning Format
@@ -86,6 +86,8 @@ List Of Warnings
Limitations`.
.. t_dist_docs_style restart_sort
.. option:: ALWCOMBORDER
.. TODO better example
@@ -445,6 +447,18 @@ List Of Warnings
correctly.
.. option:: COVERIGN
Warns that Verilator does not support certain forms of
:code:`covergroup`, :code:`coverpoint`, and coverage options, and the
construct was are ignored.
Disabling the :option:`UNSUPPORTED` error also disables this warning.
Ignoring this warning may make Verilator ignore lint checking on the
construct, and collect coverage data differently from other simulators.
.. option:: DECLFILENAME
.. TODO better example
@@ -460,6 +474,31 @@ List Of Warnings
correctly.
.. option:: DEFOVERRIDE
Warns that a macro definition within the code is being overridden by a command line directive:
For example, running Verilator with :code:`<+define+\<DUP\>=\<def2\>>` and
.. code-block:: sv
:linenos:
:emphasize-lines: 1
`define DUP def2 //<--- Warning
Results in:
.. code-block::
%Warning-DEFOVERRIDE: example.v1:20: Overriding define: 'DEF' with value: 'def2' to existing command line define value: 'def1'
... Location of previous definition, with value: '50'
While not explicitly stated in the IEEE 1800-2023 standard, this warning
tracks with the other simulators' behavior of overriding macro
definitions within code files with the definition passed in through
the command line.
.. option:: DEFPARAM
Warns that the :code:`defparam` statement was deprecated in IEEE 1364-2001,
@@ -1210,13 +1249,6 @@ List Of Warnings
simulate correctly.
.. option:: NOTIMING
Error when a timing-related construct that requires :vlopt:`--timing` has
been encountered. Issued only if Verilator is run with the
:vlopt:`--no-timing` option.
.. option:: NONSTD
Warns when a non-standard language feature is used that has a standard
@@ -1225,6 +1257,13 @@ List Of Warnings
:code:`$sformatf`.
.. option:: NOTIMING
Error when a timing-related construct that requires :vlopt:`--timing` has
been encountered. Issued only if Verilator is run with the
:vlopt:`--no-timing` option.
.. option:: NULLPORT
Warns that a null port was detected in the module definition port
@@ -1249,6 +1288,7 @@ List Of Warnings
Ignoring this warning will only suppress the lint check; it will
simulate correctly.
.. option:: PINCONNECTEMPTY
.. TODO better example
@@ -1337,6 +1377,26 @@ List Of Warnings
This error may be disabled with a lint_off PINNOTFOUND metacomment.
.. option:: PKGNODECL
An error that a package/class appears to have been referenced that has
not yet been declared. According to IEEE 1800-2023 26.3, all packages
must be declared before being used.
Faulty example:
.. include:: ../../docs/gen/ex_PKGNODECL_faulty.rst
Results in:
.. include:: ../../docs/gen/ex_PKGNODECL_msg.rst
Often the package is declared in its own header file. In this case add
an include of that package header file to the referencing file. (And
make sure you have header guards in the package's header file to prevent
multiple declarations of the package.)
.. option:: PORTSHORT
Warns that an output port is connected to a constant.
@@ -1360,26 +1420,6 @@ List Of Warnings
This error may be disabled with a lint_off PORTSHORT metacomment.
.. option:: PKGNODECL
An error that a package/class appears to have been referenced that has
not yet been declared. According to IEEE 1800-2023 26.3, all packages
must be declared before being used.
Faulty example:
.. include:: ../../docs/gen/ex_PKGNODECL_faulty.rst
Results in:
.. include:: ../../docs/gen/ex_PKGNODECL_msg.rst
Often the package is declared in its own header file. In this case add
an include of that package header file to the referencing file. (And
make sure you have header guards in the package's header file to prevent
multiple declarations of the package.)
.. option:: PREPROCZERO
Warns that a preprocessor \`ifdef/\`ifndef expression (added in IEEE
@@ -2009,12 +2049,12 @@ List Of Warnings
.. code-block:: sv
wire _unused_ok = &{1'b0,
wire _unused_ok = 1'b0 && &{1'b0,
sig_not_used_a,
sig_not_used_yet_b, // To be fixed
1'b0};
The reduction AND and constant zeros mean the net will always be zero,
The AND with constant zero mean the net will always be zero,
so won't use simulation runtime. The redundant leading and trailing
zeros avoid syntax errors if there are no signals between them. The
magic name "unused" (controlled by the :vlopt:`--unused-regexp` option)
@@ -2169,21 +2209,6 @@ List Of Warnings
.. include:: ../../docs/gen/ex_WIDTHEXPAND_1_fixed.rst
.. option:: WIDTHTRUNC
A more granular :option:`WIDTH` warning, for when a value is
truncated. See :option:`WIDTH`.
.. option:: WIDTHEXPAND
A more granular :option:`WIDTH` warning, for when a value is zero
expanded. See :option:`WIDTH`.
.. option:: WIDTHXZEXPAND
A more granular :option:`WIDTH` warning, for when a value is X/Z
expanded. See :option:`WIDTH`.
.. option:: WIDTHCONCAT
Warns that based on the width rules of Verilog, a concatenate, or
@@ -2209,6 +2234,21 @@ List Of Warnings
width to the parameter usage (:code:`{PAR[31:0], PAR[31:0]}`).
.. option:: WIDTHEXPAND
A more granular :option:`WIDTH` warning, for when a value is zero
expanded. See :option:`WIDTH`.
.. option:: WIDTHTRUNC
A more granular :option:`WIDTH` warning, for when a value is
truncated. See :option:`WIDTH`.
.. option:: WIDTHXZEXPAND
A more granular :option:`WIDTH` warning, for when a value is X/Z
expanded. See :option:`WIDTH`.
.. option:: ZERODLY
Warns that `#0` delays do not schedule the process to be resumed in the
+9 -1
View File
@@ -2046,6 +2046,11 @@ driver.py Non-Scenario Arguments
Same as ``verilator --debugi level``: Set Verilator internal debugging
level globally to the specified debug level (1-10).
--driver-clean
After a test passes, remove the generated objects. Reduces storage
requirements, but may result in longer runtime if the tests are run
again.
--dump-tree
Same as ``verilator --dump-tree``: Enable Verilator writing .tree debug
files with dumping level 3, which dumps the standard critical stages.
@@ -2077,7 +2082,10 @@ driver.py Non-Scenario Arguments
--j #
Run number of parallel tests, or 0 to determine the count based on the
number of cores installed. Requires Perl's Parallel::Forker package.
number of cores installed.
--obj-suffix <name>
Append the argument to the name of the ``test_regress/obj_`` directories.
--quiet
Suppress all output except for failures and progress messages every 15
+12
View File
@@ -19,6 +19,7 @@ Asciidoc
Ashutosh
Ast
Atmel
Augustin
Aurelien
Badáň
Bagri
@@ -104,10 +105,12 @@ Eiler
Eivind
El
Elbourne
Elzeftawi
Embecosm
Engstrom
Enzo
Eugen
Fabre
Fabrizio
Faucher
Faure
@@ -362,6 +365,7 @@ Sanguinetti
Sanjay
Sasselli
Scharrer
Schless
Seitz
Shahid
Shahrestani
@@ -648,6 +652,7 @@ elike
elsif
endcase
endcelldefine
endclass
endfunction
endgenerate
endian
@@ -858,6 +863,7 @@ noprivate
noreturn
notif
nullptr
numactl
onehot
ooo
oprofile
@@ -901,6 +907,7 @@ predefines
prepareClone
prepend
prepended
preproc
preprocess
preprocessed
preprocessing
@@ -957,6 +964,7 @@ runtime
runtimes
rw
sVerilator
saif
sawatzke
sc
scalared
@@ -1015,6 +1023,7 @@ swrite
synthesizeable
sys
systemc
tcmalloc
tenghtt
testbench
threadsafe
@@ -1090,7 +1099,9 @@ verilator
verilog
verilogmod
verimake
veriuser
vl
vlSelf
vlopt
vlt
vltstd
@@ -1110,6 +1121,7 @@ vpiUndefined
vpm
vpp
warmup
wavealloca
waveforms
whitespace
widthed
+2
View File
@@ -20,9 +20,11 @@
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
######################################################################
+2
View File
@@ -20,9 +20,11 @@
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
######################################################################
+2
View File
@@ -20,9 +20,11 @@
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
######################################################################
+1 -1
View File
@@ -36,7 +36,7 @@ add_executable(example ../make_tracing_c/sim_main.cpp)
target_compile_features(example PUBLIC cxx_std_14)
# Add the Verilated circuit to the target
verilate(example COVERAGE TRACE
verilate(example COVERAGE TRACE_VCD
INCLUDE_DIRS "../make_tracing_c"
VERILATOR_ARGS -f ../make_tracing_c/input.vc -x-assign fast
SOURCES ../make_tracing_c/top.v
+3 -1
View File
@@ -20,9 +20,11 @@
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
######################################################################
@@ -59,7 +61,7 @@ run:
@echo
@echo "-- RUN ---------------------"
@mkdir -p logs
build/example +trace
build/example +trace_vcd
@echo
@echo "-- COVERAGE ----------------"
+1 -1
View File
@@ -46,7 +46,7 @@ target_compile_features(example PUBLIC cxx_std_14)
set_property(TARGET example PROPERTY CXX_STANDARD ${SystemC_CXX_STANDARD})
# Add the Verilated circuit to the target
verilate(example SYSTEMC COVERAGE TRACE
verilate(example COVERAGE SYSTEMC TRACE_VCD
INCLUDE_DIRS "../make_tracing_sc"
VERILATOR_ARGS -f ../make_tracing_sc/input.vc -x-assign fast
SOURCES ../make_tracing_sc/top.v
+3 -1
View File
@@ -20,9 +20,11 @@
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
######################################################################
@@ -77,7 +79,7 @@ run:
@echo
@echo "-- RUN ---------------------"
@mkdir -p logs
build/example +trace
build/example +trace_vcd
@echo
@echo "-- COVERAGE ----------------"
+1 -1
View File
@@ -43,7 +43,7 @@ VERILATOR_FLAGS += -Wall
VERILATOR_FLAGS += -CFLAGS -DVL_TIME_CONTEXT
# Make waveforms
TOP_VERILATOR_FLAGS = $(VERILATOR_FLAGS) --trace
TOP_VERILATOR_FLAGS = $(VERILATOR_FLAGS) --trace-vcd
######################################################################
default: run
+1 -1
View File
@@ -40,7 +40,7 @@ VERILATOR_FLAGS += -x-assign fast
# Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall
# Make waveforms
VERILATOR_FLAGS += --trace
VERILATOR_FLAGS += --trace-vcd
# Check SystemVerilog assertions
VERILATOR_FLAGS += --assert
# Generate coverage analysis
+1 -1
View File
@@ -41,7 +41,7 @@ VERILATOR_FLAGS += -x-assign fast
# Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall
# Make waveforms
VERILATOR_FLAGS += --trace
VERILATOR_FLAGS += --trace-vcd
# Check SystemVerilog assertions
VERILATOR_FLAGS += --assert
# Generate coverage analysis
+5001 -5218
View File
File diff suppressed because it is too large Load Diff
+405 -324
View File
@@ -26,7 +26,8 @@
#define FST_API_H
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include <stdio.h>
@@ -36,428 +37,508 @@ extern "C" {
#include <zlib.h>
#include <inttypes.h>
#if defined(_MSC_VER)
#include "fst_win_unistd.h"
#include "fst_win_unistd.h"
#else
#include <unistd.h>
#include <unistd.h>
#endif
#include <time.h>
#define FST_RDLOAD "FSTLOAD | "
typedef uint32_t fstHandle;
typedef uint32_t fstEnumHandle;
enum fstWriterPackType {
FST_WR_PT_ZLIB = 0,
FST_WR_PT_FASTLZ = 1,
FST_WR_PT_LZ4 = 2
enum fstWriterPackType
{
FST_WR_PT_ZLIB = 0,
FST_WR_PT_FASTLZ = 1,
FST_WR_PT_LZ4 = 2
};
enum fstFileType {
FST_FT_MIN = 0,
enum fstFileType
{
FST_FT_MIN = 0,
FST_FT_VERILOG = 0,
FST_FT_VHDL = 1,
FST_FT_VERILOG_VHDL = 2,
FST_FT_VERILOG = 0,
FST_FT_VHDL = 1,
FST_FT_VERILOG_VHDL = 2,
FST_FT_MAX = 2
FST_FT_MAX = 2
};
enum fstBlockType {
FST_BL_HDR = 0,
FST_BL_VCDATA = 1,
FST_BL_BLACKOUT = 2,
FST_BL_GEOM = 3,
FST_BL_HIER = 4,
FST_BL_VCDATA_DYN_ALIAS = 5,
FST_BL_HIER_LZ4 = 6,
FST_BL_HIER_LZ4DUO = 7,
FST_BL_VCDATA_DYN_ALIAS2 = 8,
enum fstBlockType
{
FST_BL_HDR = 0,
FST_BL_VCDATA = 1,
FST_BL_BLACKOUT = 2,
FST_BL_GEOM = 3,
FST_BL_HIER = 4,
FST_BL_VCDATA_DYN_ALIAS = 5,
FST_BL_HIER_LZ4 = 6,
FST_BL_HIER_LZ4DUO = 7,
FST_BL_VCDATA_DYN_ALIAS2 = 8,
FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */
FST_BL_SKIP = 255 /* used while block is being written */
FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */
FST_BL_SKIP = 255 /* used while block is being written */
};
enum fstScopeType {
FST_ST_MIN = 0,
enum fstScopeType
{
FST_ST_MIN = 0,
FST_ST_VCD_MODULE = 0,
FST_ST_VCD_TASK = 1,
FST_ST_VCD_FUNCTION = 2,
FST_ST_VCD_BEGIN = 3,
FST_ST_VCD_FORK = 4,
FST_ST_VCD_GENERATE = 5,
FST_ST_VCD_STRUCT = 6,
FST_ST_VCD_UNION = 7,
FST_ST_VCD_CLASS = 8,
FST_ST_VCD_INTERFACE = 9,
FST_ST_VCD_PACKAGE = 10,
FST_ST_VCD_PROGRAM = 11,
FST_ST_VCD_MODULE = 0,
FST_ST_VCD_TASK = 1,
FST_ST_VCD_FUNCTION = 2,
FST_ST_VCD_BEGIN = 3,
FST_ST_VCD_FORK = 4,
FST_ST_VCD_GENERATE = 5,
FST_ST_VCD_STRUCT = 6,
FST_ST_VCD_UNION = 7,
FST_ST_VCD_CLASS = 8,
FST_ST_VCD_INTERFACE = 9,
FST_ST_VCD_PACKAGE = 10,
FST_ST_VCD_PROGRAM = 11,
FST_ST_VHDL_ARCHITECTURE = 12,
FST_ST_VHDL_PROCEDURE = 13,
FST_ST_VHDL_FUNCTION = 14,
FST_ST_VHDL_RECORD = 15,
FST_ST_VHDL_PROCESS = 16,
FST_ST_VHDL_BLOCK = 17,
FST_ST_VHDL_FOR_GENERATE = 18,
FST_ST_VHDL_IF_GENERATE = 19,
FST_ST_VHDL_GENERATE = 20,
FST_ST_VHDL_PACKAGE = 21,
FST_ST_VHDL_ARCHITECTURE = 12,
FST_ST_VHDL_PROCEDURE = 13,
FST_ST_VHDL_FUNCTION = 14,
FST_ST_VHDL_RECORD = 15,
FST_ST_VHDL_PROCESS = 16,
FST_ST_VHDL_BLOCK = 17,
FST_ST_VHDL_FOR_GENERATE = 18,
FST_ST_VHDL_IF_GENERATE = 19,
FST_ST_VHDL_GENERATE = 20,
FST_ST_VHDL_PACKAGE = 21,
FST_ST_MAX = 21,
FST_ST_MAX = 21,
FST_ST_GEN_ATTRBEGIN = 252,
FST_ST_GEN_ATTREND = 253,
FST_ST_GEN_ATTRBEGIN = 252,
FST_ST_GEN_ATTREND = 253,
FST_ST_VCD_SCOPE = 254,
FST_ST_VCD_UPSCOPE = 255
FST_ST_VCD_SCOPE = 254,
FST_ST_VCD_UPSCOPE = 255
};
enum fstVarType {
FST_VT_MIN = 0, /* start of vartypes */
enum fstVarType
{
FST_VT_MIN = 0, /* start of vartypes */
FST_VT_VCD_EVENT = 0,
FST_VT_VCD_INTEGER = 1,
FST_VT_VCD_PARAMETER = 2,
FST_VT_VCD_REAL = 3,
FST_VT_VCD_REAL_PARAMETER = 4,
FST_VT_VCD_REG = 5,
FST_VT_VCD_SUPPLY0 = 6,
FST_VT_VCD_SUPPLY1 = 7,
FST_VT_VCD_TIME = 8,
FST_VT_VCD_TRI = 9,
FST_VT_VCD_TRIAND = 10,
FST_VT_VCD_TRIOR = 11,
FST_VT_VCD_TRIREG = 12,
FST_VT_VCD_TRI0 = 13,
FST_VT_VCD_TRI1 = 14,
FST_VT_VCD_WAND = 15,
FST_VT_VCD_WIRE = 16,
FST_VT_VCD_WOR = 17,
FST_VT_VCD_PORT = 18,
FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */
FST_VT_VCD_REALTIME = 20,
FST_VT_VCD_EVENT = 0,
FST_VT_VCD_INTEGER = 1,
FST_VT_VCD_PARAMETER = 2,
FST_VT_VCD_REAL = 3,
FST_VT_VCD_REAL_PARAMETER = 4,
FST_VT_VCD_REG = 5,
FST_VT_VCD_SUPPLY0 = 6,
FST_VT_VCD_SUPPLY1 = 7,
FST_VT_VCD_TIME = 8,
FST_VT_VCD_TRI = 9,
FST_VT_VCD_TRIAND = 10,
FST_VT_VCD_TRIOR = 11,
FST_VT_VCD_TRIREG = 12,
FST_VT_VCD_TRI0 = 13,
FST_VT_VCD_TRI1 = 14,
FST_VT_VCD_WAND = 15,
FST_VT_VCD_WIRE = 16,
FST_VT_VCD_WOR = 17,
FST_VT_VCD_PORT = 18,
FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */
FST_VT_VCD_REALTIME = 20,
FST_VT_GEN_STRING = 21, /* generic string type (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */
FST_VT_GEN_STRING = 21, /* generic string type (max len is defined dynamically via
fstWriterEmitVariableLengthValueChange) */
FST_VT_SV_BIT = 22,
FST_VT_SV_LOGIC = 23,
FST_VT_SV_INT = 24, /* declare as size = 32 */
FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */
FST_VT_SV_LONGINT = 26, /* declare as size = 64 */
FST_VT_SV_BYTE = 27, /* declare as size = 8 */
FST_VT_SV_ENUM = 28, /* declare as appropriate type range */
FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */
FST_VT_SV_BIT = 22,
FST_VT_SV_LOGIC = 23,
FST_VT_SV_INT = 24, /* declare as size = 32 */
FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */
FST_VT_SV_LONGINT = 26, /* declare as size = 64 */
FST_VT_SV_BYTE = 27, /* declare as size = 8 */
FST_VT_SV_ENUM = 28, /* declare as appropriate type range */
FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted
as double, not a float) */
FST_VT_MAX = 29 /* end of vartypes */
FST_VT_MAX = 29 /* end of vartypes */
};
enum fstVarDir {
FST_VD_MIN = 0,
enum fstVarDir
{
FST_VD_MIN = 0,
FST_VD_IMPLICIT = 0,
FST_VD_INPUT = 1,
FST_VD_OUTPUT = 2,
FST_VD_INOUT = 3,
FST_VD_BUFFER = 4,
FST_VD_LINKAGE = 5,
FST_VD_IMPLICIT = 0,
FST_VD_INPUT = 1,
FST_VD_OUTPUT = 2,
FST_VD_INOUT = 3,
FST_VD_BUFFER = 4,
FST_VD_LINKAGE = 5,
FST_VD_MAX = 5
FST_VD_MAX = 5
};
enum fstHierType {
FST_HT_MIN = 0,
enum fstHierType
{
FST_HT_MIN = 0,
FST_HT_SCOPE = 0,
FST_HT_UPSCOPE = 1,
FST_HT_VAR = 2,
FST_HT_ATTRBEGIN = 3,
FST_HT_ATTREND = 4,
FST_HT_SCOPE = 0,
FST_HT_UPSCOPE = 1,
FST_HT_VAR = 2,
FST_HT_ATTRBEGIN = 3,
FST_HT_ATTREND = 4,
/* FST_HT_TREEBEGIN and FST_HT_TREEEND are not yet used by FST but are currently used when fstHier bridges other formats */
FST_HT_TREEBEGIN = 5,
FST_HT_TREEEND = 6,
/* FST_HT_TREEBEGIN and FST_HT_TREEEND are not yet used by FST but are currently used when
fstHier bridges other formats */
FST_HT_TREEBEGIN = 5,
FST_HT_TREEEND = 6,
FST_HT_MAX = 6
FST_HT_MAX = 6
};
enum fstAttrType {
FST_AT_MIN = 0,
enum fstAttrType
{
FST_AT_MIN = 0,
FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */
FST_AT_ARRAY = 1,
FST_AT_ENUM = 2,
FST_AT_PACK = 3,
FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */
FST_AT_ARRAY = 1,
FST_AT_ENUM = 2,
FST_AT_PACK = 3,
FST_AT_MAX = 3
FST_AT_MAX = 3
};
enum fstMiscType {
FST_MT_MIN = 0,
enum fstMiscType
{
FST_MT_MIN = 0,
FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */
FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */
FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */
FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */
FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */
FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */
FST_MT_VALUELIST = 6, /* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */
FST_MT_ENUMTABLE = 7, /* use fstWriterCreateEnumTable() and fstWriterEmitEnumTableRef() to emit */
FST_MT_UNKNOWN = 8,
FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */
FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */
FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */
FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */
FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */
FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */
FST_MT_VALUELIST =
6, /* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */
FST_MT_ENUMTABLE =
7, /* use fstWriterCreateEnumTable() and fstWriterEmitEnumTableRef() to emit */
FST_MT_UNKNOWN = 8,
FST_MT_MAX = 8
FST_MT_MAX = 8
};
enum fstArrayType {
FST_AR_MIN = 0,
enum fstArrayType
{
FST_AR_MIN = 0,
FST_AR_NONE = 0,
FST_AR_UNPACKED = 1,
FST_AR_PACKED = 2,
FST_AR_SPARSE = 3,
FST_AR_NONE = 0,
FST_AR_UNPACKED = 1,
FST_AR_PACKED = 2,
FST_AR_SPARSE = 3,
FST_AR_MAX = 3
FST_AR_MAX = 3
};
enum fstEnumValueType {
FST_EV_SV_INTEGER = 0,
FST_EV_SV_BIT = 1,
FST_EV_SV_LOGIC = 2,
FST_EV_SV_INT = 3,
FST_EV_SV_SHORTINT = 4,
FST_EV_SV_LONGINT = 5,
FST_EV_SV_BYTE = 6,
FST_EV_SV_UNSIGNED_INTEGER = 7,
FST_EV_SV_UNSIGNED_BIT = 8,
FST_EV_SV_UNSIGNED_LOGIC = 9,
FST_EV_SV_UNSIGNED_INT = 10,
enum fstEnumValueType
{
FST_EV_SV_INTEGER = 0,
FST_EV_SV_BIT = 1,
FST_EV_SV_LOGIC = 2,
FST_EV_SV_INT = 3,
FST_EV_SV_SHORTINT = 4,
FST_EV_SV_LONGINT = 5,
FST_EV_SV_BYTE = 6,
FST_EV_SV_UNSIGNED_INTEGER = 7,
FST_EV_SV_UNSIGNED_BIT = 8,
FST_EV_SV_UNSIGNED_LOGIC = 9,
FST_EV_SV_UNSIGNED_INT = 10,
FST_EV_SV_UNSIGNED_SHORTINT = 11,
FST_EV_SV_UNSIGNED_LONGINT = 12,
FST_EV_SV_UNSIGNED_BYTE = 13,
FST_EV_SV_UNSIGNED_LONGINT = 12,
FST_EV_SV_UNSIGNED_BYTE = 13,
FST_EV_REG = 14,
FST_EV_TIME = 15,
FST_EV_REG = 14,
FST_EV_TIME = 15,
FST_EV_MAX = 15
FST_EV_MAX = 15
};
enum fstPackType {
FST_PT_NONE = 0,
FST_PT_UNPACKED = 1,
FST_PT_PACKED = 2,
enum fstPackType
{
FST_PT_NONE = 0,
FST_PT_UNPACKED = 1,
FST_PT_PACKED = 2,
FST_PT_TAGGED_PACKED = 3,
FST_PT_MAX = 3
FST_PT_MAX = 3
};
enum fstSupplementalVarType {
FST_SVT_MIN = 0,
enum fstSupplementalVarType
{
FST_SVT_MIN = 0,
FST_SVT_NONE = 0,
FST_SVT_NONE = 0,
FST_SVT_VHDL_SIGNAL = 1,
FST_SVT_VHDL_VARIABLE = 2,
FST_SVT_VHDL_CONSTANT = 3,
FST_SVT_VHDL_FILE = 4,
FST_SVT_VHDL_MEMORY = 5,
FST_SVT_VHDL_SIGNAL = 1,
FST_SVT_VHDL_VARIABLE = 2,
FST_SVT_VHDL_CONSTANT = 3,
FST_SVT_VHDL_FILE = 4,
FST_SVT_VHDL_MEMORY = 5,
FST_SVT_MAX = 5
FST_SVT_MAX = 5
};
enum fstSupplementalDataType {
FST_SDT_MIN = 0,
enum fstSupplementalDataType
{
FST_SDT_MIN = 0,
FST_SDT_NONE = 0,
FST_SDT_NONE = 0,
FST_SDT_VHDL_BOOLEAN = 1,
FST_SDT_VHDL_BIT = 2,
FST_SDT_VHDL_BIT_VECTOR = 3,
FST_SDT_VHDL_STD_ULOGIC = 4,
FST_SDT_VHDL_BOOLEAN = 1,
FST_SDT_VHDL_BIT = 2,
FST_SDT_VHDL_BIT_VECTOR = 3,
FST_SDT_VHDL_STD_ULOGIC = 4,
FST_SDT_VHDL_STD_ULOGIC_VECTOR = 5,
FST_SDT_VHDL_STD_LOGIC = 6,
FST_SDT_VHDL_STD_LOGIC_VECTOR = 7,
FST_SDT_VHDL_UNSIGNED = 8,
FST_SDT_VHDL_SIGNED = 9,
FST_SDT_VHDL_INTEGER = 10,
FST_SDT_VHDL_REAL = 11,
FST_SDT_VHDL_NATURAL = 12,
FST_SDT_VHDL_POSITIVE = 13,
FST_SDT_VHDL_TIME = 14,
FST_SDT_VHDL_CHARACTER = 15,
FST_SDT_VHDL_STRING = 16,
FST_SDT_VHDL_STD_LOGIC = 6,
FST_SDT_VHDL_STD_LOGIC_VECTOR = 7,
FST_SDT_VHDL_UNSIGNED = 8,
FST_SDT_VHDL_SIGNED = 9,
FST_SDT_VHDL_INTEGER = 10,
FST_SDT_VHDL_REAL = 11,
FST_SDT_VHDL_NATURAL = 12,
FST_SDT_VHDL_POSITIVE = 13,
FST_SDT_VHDL_TIME = 14,
FST_SDT_VHDL_CHARACTER = 15,
FST_SDT_VHDL_STRING = 16,
FST_SDT_MAX = 16,
FST_SDT_MAX = 16,
FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left after shifting FST_SDT_SVT_SHIFT_COUNT */
FST_SDT_ABS_MAX = ((1<<(FST_SDT_SVT_SHIFT_COUNT))-1)
FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left
after shifting FST_SDT_SVT_SHIFT_COUNT */
FST_SDT_ABS_MAX = ((1 << (FST_SDT_SVT_SHIFT_COUNT)) - 1)
};
struct fstHier
{
unsigned char htyp;
unsigned char htyp;
union {
union
{
/* if htyp == FST_HT_SCOPE */
struct fstHierScope {
unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */
const char *name;
const char *component;
uint32_t name_length; /* strlen(u.scope.name) */
uint32_t component_length; /* strlen(u.scope.component) */
} scope;
struct fstHierScope
{
unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */
const char *name;
const char *component;
uint32_t name_length; /* strlen(u.scope.name) */
uint32_t component_length; /* strlen(u.scope.component) */
} scope;
/* if htyp == FST_HT_VAR */
struct fstHierVar {
unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */
unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */
unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */
unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */
unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */
const char *name;
uint32_t length;
fstHandle handle;
uint32_t name_length; /* strlen(u.var.name) */
unsigned is_alias : 1;
} var;
struct fstHierVar
{
unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */
unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */
unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */
unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */
unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */
const char *name;
uint32_t length;
fstHandle handle;
uint32_t name_length; /* strlen(u.var.name) */
unsigned is_alias : 1;
} var;
/* if htyp == FST_HT_ATTRBEGIN */
struct fstHierAttr {
unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */
unsigned char subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */
const char *name;
uint64_t arg; /* number of array elements, struct members, or some other payload (possibly ignored) */
uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */
uint32_t name_length; /* strlen(u.attr.name) */
} attr;
} u;
struct fstHierAttr
{
unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */
unsigned char
subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */
const char *name;
uint64_t arg; /* number of array elements, struct members, or some other payload
(possibly ignored) */
uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer
(FST_AT_MISC + FST_MT_SOURCESTEM) */
uint32_t name_length; /* strlen(u.attr.name) */
} attr;
} u;
};
struct fstETab
{
char *name;
uint32_t elem_count;
char **literal_arr;
char **val_arr;
char *name;
uint32_t elem_count;
char **literal_arr;
char **val_arr;
};
/*
* writer functions
*/
void fstWriterClose(void *ctx);
void * fstWriterCreate(const char *nam, int use_compressed_hier);
fstEnumHandle fstWriterCreateEnumTable(void *ctx, const char *name, uint32_t elem_count, unsigned int min_valbits, const char **literal_arr, const char **val_arr);
/* used for Verilog/SV */
fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd,
uint32_t len, const char *nam, fstHandle aliasHandle);
/* future expansion for VHDL and other languages. The variable type, data type, etc map onto
the current Verilog/SV one. The "type" string is optional for a more verbose or custom description */
fstHandle fstWriterCreateVar2(void *ctx, enum fstVarType vt, enum fstVarDir vd,
uint32_t len, const char *nam, fstHandle aliasHandle,
const char *type, enum fstSupplementalVarType svt, enum fstSupplementalDataType sdt);
void fstWriterEmitDumpActive(void *ctx, int enable);
void fstWriterEmitEnumTableRef(void *ctx, fstEnumHandle handle);
void fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val);
void fstWriterEmitValueChange32(void *ctx, fstHandle handle,
uint32_t bits, uint32_t val);
void fstWriterEmitValueChange64(void *ctx, fstHandle handle,
uint32_t bits, uint64_t val);
void fstWriterEmitValueChangeVec32(void *ctx, fstHandle handle,
uint32_t bits, const uint32_t *val);
void fstWriterEmitValueChangeVec64(void *ctx, fstHandle handle,
uint32_t bits, const uint64_t *val);
void fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len);
void fstWriterEmitTimeChange(void *ctx, uint64_t tim);
void fstWriterFlushContext(void *ctx);
int fstWriterGetDumpSizeLimitReached(void *ctx);
int fstWriterGetFseekFailed(void *ctx);
void fstWriterSetAttrBegin(void *ctx, enum fstAttrType attrtype, int subtype,
const char *attrname, uint64_t arg);
void fstWriterSetAttrEnd(void *ctx);
void fstWriterSetComment(void *ctx, const char *comm);
void fstWriterSetDate(void *ctx, const char *dat);
void fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes);
void fstWriterSetEnvVar(void *ctx, const char *envvar);
void fstWriterSetFileType(void *ctx, enum fstFileType filetype);
void fstWriterSetPackType(void *ctx, enum fstWriterPackType typ);
void fstWriterSetParallelMode(void *ctx, int enable);
void fstWriterSetRepackOnClose(void *ctx, int enable); /* type = 0 (none), 1 (libz) */
void fstWriterSetScope(void *ctx, enum fstScopeType scopetype,
const char *scopename, const char *scopecomp);
void fstWriterSetSourceInstantiationStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
void fstWriterSetSourceStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath);
void fstWriterSetTimescale(void *ctx, int ts);
void fstWriterSetTimescaleFromString(void *ctx, const char *s);
void fstWriterSetTimezero(void *ctx, int64_t tim);
void fstWriterSetUpscope(void *ctx);
void fstWriterSetValueList(void *ctx, const char *vl);
void fstWriterSetVersion(void *ctx, const char *vers);
typedef struct fstWriterContext fstWriterContext;
void fstWriterClose(fstWriterContext *ctx);
fstWriterContext *fstWriterCreate(const char *nam, int use_compressed_hier);
fstEnumHandle fstWriterCreateEnumTable(fstWriterContext *ctx,
const char *name,
uint32_t elem_count,
unsigned int min_valbits,
const char **literal_arr,
const char **val_arr);
/* used for Verilog/SV */
fstHandle fstWriterCreateVar(fstWriterContext *ctx,
enum fstVarType vt,
enum fstVarDir vd,
uint32_t len,
const char *nam,
fstHandle aliasHandle);
/* future expansion for VHDL and other languages. The variable type, data type, etc map onto
the current Verilog/SV one. The "type" string is optional for a more verbose or custom
description */
fstHandle fstWriterCreateVar2(fstWriterContext *ctx,
enum fstVarType vt,
enum fstVarDir vd,
uint32_t len,
const char *nam,
fstHandle aliasHandle,
const char *type,
enum fstSupplementalVarType svt,
enum fstSupplementalDataType sdt);
void fstWriterEmitDumpActive(fstWriterContext *ctx, int enable);
void fstWriterEmitEnumTableRef(fstWriterContext *ctx, fstEnumHandle handle);
void fstWriterEmitValueChange(fstWriterContext *ctx, fstHandle handle, const void *val);
void fstWriterEmitValueChange32(fstWriterContext *ctx,
fstHandle handle,
uint32_t bits,
uint32_t val);
void fstWriterEmitValueChange64(fstWriterContext *ctx,
fstHandle handle,
uint32_t bits,
uint64_t val);
void fstWriterEmitValueChangeVec32(fstWriterContext *ctx,
fstHandle handle,
uint32_t bits,
const uint32_t *val);
void fstWriterEmitValueChangeVec64(fstWriterContext *ctx,
fstHandle handle,
uint32_t bits,
const uint64_t *val);
void fstWriterEmitVariableLengthValueChange(fstWriterContext *ctx,
fstHandle handle,
const void *val,
uint32_t len);
void fstWriterEmitTimeChange(fstWriterContext *ctx, uint64_t tim);
void fstWriterFlushContext(fstWriterContext *ctx);
int fstWriterGetDumpSizeLimitReached(fstWriterContext *ctx);
int fstWriterGetFseekFailed(fstWriterContext *ctx);
int fstWriterGetFlushContextPending(fstWriterContext *ctx);
void fstWriterSetAttrBegin(fstWriterContext *ctx,
enum fstAttrType attrtype,
int subtype,
const char *attrname,
uint64_t arg);
void fstWriterSetAttrEnd(fstWriterContext *ctx);
void fstWriterSetComment(fstWriterContext *ctx, const char *comm);
void fstWriterSetDate(fstWriterContext *ctx, const char *dat);
void fstWriterSetDumpSizeLimit(fstWriterContext *ctx, uint64_t numbytes);
void fstWriterSetEnvVar(fstWriterContext *ctx, const char *envvar);
void fstWriterSetFileType(fstWriterContext *ctx, enum fstFileType filetype);
void fstWriterSetPackType(fstWriterContext *ctx, enum fstWriterPackType typ);
void fstWriterSetParallelMode(fstWriterContext *ctx, int enable);
void fstWriterSetRepackOnClose(fstWriterContext *ctx,
int enable); /* type = 0 (none), 1 (libz) */
void fstWriterSetScope(fstWriterContext *ctx,
enum fstScopeType scopetype,
const char *scopename,
const char *scopecomp);
void fstWriterSetSourceInstantiationStem(fstWriterContext *ctx,
const char *path,
unsigned int line,
unsigned int use_realpath);
void fstWriterSetSourceStem(fstWriterContext *ctx,
const char *path,
unsigned int line,
unsigned int use_realpath);
void fstWriterSetTimescale(fstWriterContext *ctx, int ts);
void fstWriterSetTimescaleFromString(fstWriterContext *ctx, const char *s);
void fstWriterSetTimezero(fstWriterContext *ctx, int64_t tim);
void fstWriterSetUpscope(fstWriterContext *ctx);
void fstWriterSetValueList(fstWriterContext *ctx, const char *vl);
void fstWriterSetVersion(fstWriterContext *ctx, const char *vers);
/*
* reader functions
*/
void fstReaderClose(void *ctx);
void fstReaderClrFacProcessMask(void *ctx, fstHandle facidx);
void fstReaderClrFacProcessMaskAll(void *ctx);
uint64_t fstReaderGetAliasCount(void *ctx);
const char * fstReaderGetCurrentFlatScope(void *ctx);
void * fstReaderGetCurrentScopeUserInfo(void *ctx);
int fstReaderGetCurrentScopeLen(void *ctx);
const char * fstReaderGetDateString(void *ctx);
int fstReaderGetDoubleEndianMatchState(void *ctx);
uint64_t fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx);
unsigned char fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx);
uint64_t fstReaderGetEndTime(void *ctx);
int fstReaderGetFacProcessMask(void *ctx, fstHandle facidx);
int fstReaderGetFileType(void *ctx);
int fstReaderGetFseekFailed(void *ctx);
fstHandle fstReaderGetMaxHandle(void *ctx);
uint64_t fstReaderGetMemoryUsedByWriter(void *ctx);
uint32_t fstReaderGetNumberDumpActivityChanges(void *ctx);
uint64_t fstReaderGetScopeCount(void *ctx);
uint64_t fstReaderGetStartTime(void *ctx);
signed char fstReaderGetTimescale(void *ctx);
int64_t fstReaderGetTimezero(void *ctx);
uint64_t fstReaderGetValueChangeSectionCount(void *ctx);
char * fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf);
uint64_t fstReaderGetVarCount(void *ctx);
const char * fstReaderGetVersionString(void *ctx);
struct fstHier *fstReaderIterateHier(void *ctx);
int fstReaderIterateHierRewind(void *ctx);
int fstReaderIterBlocks(void *ctx,
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
void *user_callback_data_pointer, FILE *vcdhandle);
int fstReaderIterBlocks2(void *ctx,
void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value),
void (*value_change_callback_varlen)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value, uint32_t len),
void *user_callback_data_pointer, FILE *vcdhandle);
void fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable);
void * fstReaderOpen(const char *nam);
void * fstReaderOpenForUtilitiesOnly(void);
const char * fstReaderPopScope(void *ctx);
int fstReaderProcessHier(void *ctx, FILE *vcdhandle);
const char * fstReaderPushScope(void *ctx, const char *nam, void *user_info);
void fstReaderResetScope(void *ctx);
void fstReaderSetFacProcessMask(void *ctx, fstHandle facidx);
void fstReaderSetFacProcessMaskAll(void *ctx);
void fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time);
void fstReaderSetUnlimitedTimeRange(void *ctx);
void fstReaderSetVcdExtensions(void *ctx, int enable);
typedef struct fstReaderContext fstReaderContext;
void fstReaderClose(fstReaderContext *ctx);
void fstReaderClrFacProcessMask(fstReaderContext *ctx, fstHandle facidx);
void fstReaderClrFacProcessMaskAll(fstReaderContext *ctx);
uint64_t fstReaderGetAliasCount(fstReaderContext *ctx);
const char *fstReaderGetCurrentFlatScope(fstReaderContext *ctx);
void *fstReaderGetCurrentScopeUserInfo(fstReaderContext *ctx);
int fstReaderGetCurrentScopeLen(fstReaderContext *ctx);
const char *fstReaderGetDateString(fstReaderContext *ctx);
int fstReaderGetDoubleEndianMatchState(fstReaderContext *ctx);
uint64_t fstReaderGetDumpActivityChangeTime(fstReaderContext *ctx, uint32_t idx);
unsigned char fstReaderGetDumpActivityChangeValue(fstReaderContext *ctx, uint32_t idx);
uint64_t fstReaderGetEndTime(fstReaderContext *ctx);
int fstReaderGetFacProcessMask(fstReaderContext *ctx, fstHandle facidx);
int fstReaderGetFileType(fstReaderContext *ctx);
int fstReaderGetFseekFailed(fstReaderContext *ctx);
fstHandle fstReaderGetMaxHandle(fstReaderContext *ctx);
uint64_t fstReaderGetMemoryUsedByWriter(fstReaderContext *ctx);
uint32_t fstReaderGetNumberDumpActivityChanges(fstReaderContext *ctx);
uint64_t fstReaderGetScopeCount(fstReaderContext *ctx);
uint64_t fstReaderGetStartTime(fstReaderContext *ctx);
signed char fstReaderGetTimescale(fstReaderContext *ctx);
int64_t fstReaderGetTimezero(fstReaderContext *ctx);
uint64_t fstReaderGetValueChangeSectionCount(fstReaderContext *ctx);
char *fstReaderGetValueFromHandleAtTime(fstReaderContext *ctx,
uint64_t tim,
fstHandle facidx,
char *buf);
uint64_t fstReaderGetVarCount(fstReaderContext *ctx);
const char *fstReaderGetVersionString(fstReaderContext *ctx);
struct fstHier *fstReaderIterateHier(fstReaderContext *ctx);
int fstReaderIterateHierRewind(fstReaderContext *ctx);
int fstReaderIterBlocks(fstReaderContext *ctx,
void (*value_change_callback)(void *user_callback_data_pointer,
uint64_t time,
fstHandle facidx,
const unsigned char *value),
void *user_callback_data_pointer,
FILE *vcdhandle);
int fstReaderIterBlocks2(fstReaderContext *ctx,
void (*value_change_callback)(void *user_callback_data_pointer,
uint64_t time,
fstHandle facidx,
const unsigned char *value),
void (*value_change_callback_varlen)(void *user_callback_data_pointer,
uint64_t time,
fstHandle facidx,
const unsigned char *value,
uint32_t len),
void *user_callback_data_pointer,
FILE *vcdhandle);
void fstReaderIterBlocksSetNativeDoublesOnCallback(fstReaderContext *ctx, int enable);
fstReaderContext *fstReaderOpen(const char *nam);
fstReaderContext *fstReaderOpenForUtilitiesOnly(void);
const char *fstReaderPopScope(fstReaderContext *ctx);
int fstReaderProcessHier(fstReaderContext *ctx, FILE *vcdhandle);
const char *fstReaderPushScope(fstReaderContext *ctx, const char *nam, void *user_info);
void fstReaderResetScope(fstReaderContext *ctx);
void fstReaderSetFacProcessMask(fstReaderContext *ctx, fstHandle facidx);
void fstReaderSetFacProcessMaskAll(fstReaderContext *ctx);
void fstReaderSetLimitTimeRange(fstReaderContext *ctx, uint64_t start_time, uint64_t end_time);
void fstReaderSetUnlimitedTimeRange(fstReaderContext *ctx);
void fstReaderSetVcdExtensions(fstReaderContext *ctx, int enable);
/*
* utility functions
*/
int fstUtilityBinToEscConvertedLen(const unsigned char *s, int len); /* used for mallocs for fstUtilityBinToEsc() */
int fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len);
int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len);
int fstUtilityBinToEscConvertedLen(const unsigned char *s, int len); /* used for mallocs for fstUtilityBinToEsc() */
int fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len);
int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len);
struct fstETab *fstUtilityExtractEnumTableFromString(const char *s);
void fstUtilityFreeEnumTable(struct fstETab *etab); /* must use to free fstETab properly */
void fstUtilityFreeEnumTable(struct fstETab *etab); /* must use to free fstETab properly */
#ifdef __cplusplus
}
-41
View File
@@ -1,41 +0,0 @@
/*
* Copyright (c) 1999 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#ifndef WAVE_ALLOCA_H
#define WAVE_ALLOCA_H
#include <stdlib.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#elif defined(__GNUC__)
#ifndef __MINGW32__
#ifndef alloca
#define alloca __builtin_alloca
#endif
#else
#include <malloc.h>
#endif
#endif
#define wave_alloca alloca
#endif
+43 -24
View File
@@ -56,6 +56,7 @@
#include <cctype>
#include <cerrno>
#include <cstdlib>
#include <iostream>
#include <limits>
#include <list>
#include <sstream>
@@ -916,6 +917,21 @@ void _vl_vsformat(std::string& output, const std::string& format, va_list ap) VL
}
break;
}
case 'p': { // 'x' but parameter is string
const int lbits = va_arg(ap, int);
(void)lbits;
const std::string* const cstr = va_arg(ap, const std::string*);
std::ostringstream oss;
for (unsigned char c : *cstr) oss << std::hex << static_cast<int>(c);
std::string hex_str = oss.str();
if (width > 0 && widthSet) {
hex_str = hex_str.size() > width
? hex_str.substr(0, width)
: std::string(width - hex_str.size(), '0') + hex_str;
output += hex_str;
}
break;
}
default: {
// Deal with all read-and-print somethings
const int lbits = va_arg(ap, int);
@@ -1234,9 +1250,9 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
bool inPct = false;
bool inIgnore = false;
std::string::const_iterator pos = format.cbegin();
for (; pos != format.cend() && !_vl_vsss_eof(fp, floc); ++pos) {
// VL_DBG_MSGF("_vlscan fmt='"<<pos[0]<<"' floc="<<floc<<" file='"<<_vl_vsss_peek(fp, floc,
// fromp, fstr)<<"'\n");
for (; pos != format.cend(); ++pos) {
// VL_DBG_MSGF("_vlscan fmt='%c' floc=%d file='%c'\n", pos[0], floc,
// _vl_vsss_peek(fp, floc, fromp, fstr));
if (!inPct && pos[0] == '%') {
inPct = true;
inIgnore = false;
@@ -1420,7 +1436,12 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
} // switch
}
}
// Processed all arguments
return got;
done:
// Scan stopped early, return parsed or EOF
if (_vl_vsss_eof(fp, floc)) return -1;
return got;
}
@@ -1898,7 +1919,7 @@ std::string VL_TO_STRING(CData lhs) { return VL_SFORMATF_N_NX("'h%0x", 0, 8, lhs
std::string VL_TO_STRING(SData lhs) { return VL_SFORMATF_N_NX("'h%0x", 0, 16, lhs); }
std::string VL_TO_STRING(IData lhs) { return VL_SFORMATF_N_NX("'h%0x", 0, 32, lhs); }
std::string VL_TO_STRING(QData lhs) { return VL_SFORMATF_N_NX("'h%0x", 0, 64, lhs); }
std::string VL_TO_STRING(double lhs) { return VL_SFORMATF_N_NX("%d", 0, 64, lhs); }
std::string VL_TO_STRING(double lhs) { return VL_SFORMATF_N_NX("%g", 0, 64, lhs); }
std::string VL_TO_STRING_W(int words, const WDataInP obj) {
return VL_SFORMATF_N_NX("'h%0x", 0, words * VL_EDATASIZE, obj);
}
@@ -3017,7 +3038,7 @@ void VerilatedContext::trace(VerilatedTraceBaseC* tfp, int levels, int options)
if (m_ns.m_traceBaseModelCbs.empty())
VL_FATAL_MT("", 0, "",
"Testbench C call to 'VerilatedContext::trace()' requires model(s) Verilated"
" with --trace or --trace-vcd option");
" with --trace-fst or --trace-vcd option");
for (auto& cbr : m_ns.m_traceBaseModelCbs) cbr(tfp, levels, options);
}
void VerilatedContext::traceBaseModelCbAdd(traceBaseModelCb_t cb) VL_MT_SAFE {
@@ -3289,7 +3310,7 @@ uint32_t VerilatedVarProps::entSize() const VL_MT_SAFE {
case VLVT_UINT16: size = sizeof(SData); break;
case VLVT_UINT32: size = sizeof(IData); break;
case VLVT_UINT64: size = sizeof(QData); break;
case VLVT_WDATA: size = VL_WORDS_I(packed().elements()) * sizeof(IData); break;
case VLVT_WDATA: size = VL_WORDS_I(entBits()) * sizeof(IData); break;
default: size = 0; break; // LCOV_EXCL_LINE
}
return size;
@@ -3308,7 +3329,7 @@ void* VerilatedVarProps::datapAdjustIndex(void* datap, int dim, int indx) const
uint8_t* bytep = reinterpret_cast<uint8_t*>(datap);
// If on index 1 of a 2 index array, then each index 1 is index2sz*entsz
size_t slicesz = entSize();
for (int d = dim + 1; d <= m_udims; ++d) slicesz *= elements(d);
for (int d = dim + 1; d <= udims(); ++d) slicesz *= elements(d);
bytep += indxAdj * slicesz;
return bytep;
}
@@ -3369,32 +3390,30 @@ void VerilatedScope::exportInsert(int finalize, const char* namep, void* cb) VL_
}
void VerilatedScope::varInsert(int finalize, const char* namep, void* datap, bool isParam,
VerilatedVarType vltype, int vlflags, int dims, ...) VL_MT_UNSAFE {
VerilatedVarType vltype, int vlflags, int udims,
int pdims...) VL_MT_UNSAFE {
// Grab dimensions
// In the future we may just create a large table at emit time and
// statically construct from that.
if (!finalize) return;
if (!m_varsp) m_varsp = new VerilatedVarNameMap;
VerilatedVar var(namep, datap, vltype, static_cast<VerilatedVarFlags>(vlflags), dims, isParam);
VerilatedVar var(namep, datap, vltype, static_cast<VerilatedVarFlags>(vlflags), udims, pdims,
isParam);
va_list ap;
va_start(ap, dims);
for (int i = 0; i < dims; ++i) {
va_start(ap, pdims);
for (int i = 0; i < udims; ++i) {
const int msb = va_arg(ap, int);
const int lsb = va_arg(ap, int);
if (i == 0) {
var.m_packed.m_left = msb;
var.m_packed.m_right = lsb;
} else if (i >= 1 && i <= var.udims()) {
var.m_unpacked[i - 1].m_left = msb;
var.m_unpacked[i - 1].m_right = lsb;
} else {
// We could have a linked list of ranges, but really this whole thing needs
// to be generalized to support structs and unions, etc.
const std::string msg = "Unsupported multi-dimensional public varInsert: "s + namep;
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
}
var.m_unpacked[i].m_left = msb;
var.m_unpacked[i].m_right = lsb;
}
for (int i = 0; i < pdims; ++i) {
const int msb = va_arg(ap, int);
const int lsb = va_arg(ap, int);
var.m_packed[i].m_left = msb;
var.m_packed[i].m_right = lsb;
}
va_end(ap);
@@ -3457,7 +3476,7 @@ void VerilatedHierarchy::remove(VerilatedScope* fromp, VerilatedScope* top) {
void VerilatedAssertOneThread::fatal_different() VL_MT_SAFE {
VL_FATAL_MT(__FILE__, __LINE__, "",
"Routine called that is single threaded, but called from"
" a different thread then the expected constructing thread");
" a different thread than the expected constructing thread");
}
#endif
+9 -1
View File
@@ -175,6 +175,14 @@ enum class VerilatedAssertDirectiveType : uint8_t {
using VerilatedAssertType_t = std::underlying_type<VerilatedAssertType>::type;
using VerilatedAssertDirectiveType_t = std::underlying_type<VerilatedAssertDirectiveType>::type;
// Type trait: whether T is a user-defined custom struct
template <typename>
struct VlIsCustomStruct : public std::false_type {};
// Type trait: used to detect if array element is a custom struct (e.g. for struct arrays)
template <typename T>
struct VlContainsCustomStruct : VlIsCustomStruct<T> {};
//=============================================================================
// Utility functions
@@ -726,7 +734,7 @@ public: // But internals only - called from VerilatedModule's
const Type& type) VL_MT_UNSAFE;
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
void varInsert(int finalize, const char* namep, void* datap, bool isParam,
VerilatedVarType vltype, int vlflags, int dims, ...) VL_MT_UNSAFE;
VerilatedVarType vltype, int vlflags, int udims, int pdims, ...) VL_MT_UNSAFE;
// ACCESSORS
const char* name() const VL_MT_SAFE_POSTINIT { return m_namep; }
const char* identifier() const VL_MT_SAFE_POSTINIT { return m_identifierp; }
+1
View File
@@ -90,6 +90,7 @@ VK_CPPFLAGS_ALWAYS += \
-DVM_TRACE=$(VM_TRACE) \
-DVM_TRACE_FST=$(VM_TRACE_FST) \
-DVM_TRACE_VCD=$(VM_TRACE_VCD) \
-DVM_TRACE_SAIF=$(VM_TRACE_SAIF) \
$(CFG_CXXFLAGS_NO_UNUSED) \
ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users
+4 -4
View File
@@ -289,7 +289,7 @@ static void _vl_svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s,
}
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->entBits()); ++i) d[i] = wdatap[i];
return;
}
default: // LCOV_EXCL_START // Errored earlier
@@ -328,7 +328,7 @@ static void _vl_svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandl
}
case VLVT_WDATA: {
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) {
for (int i = 0; i < VL_WORDS_I(varp->entBits()); ++i) {
d[i].aval = wdatap[i];
d[i].bval = 0;
}
@@ -354,7 +354,7 @@ static void _vl_svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecV
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->entBits()); ++i) wdatap[i] = s[i];
return;
}
default: // LCOV_EXCL_START // Errored earlier
@@ -376,7 +376,7 @@ static void _vl_svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogic
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->entBits()); ++i) wdatap[i] = s[i].aval;
return;
}
default: // LCOV_EXCL_START // Errored earlier
+22 -1
View File
@@ -101,6 +101,7 @@ void VerilatedFst::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) {
void VerilatedFst::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
const VerilatedLockGuard lock{m_mutex};
Super::closeBase();
emitTimeChangeMaybe();
fstWriterClose(m_fst);
m_fst = nullptr;
}
@@ -108,10 +109,22 @@ void VerilatedFst::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
void VerilatedFst::flush() VL_MT_SAFE_EXCLUDES(m_mutex) {
const VerilatedLockGuard lock{m_mutex};
Super::flushBase();
emitTimeChangeMaybe();
fstWriterFlushContext(m_fst);
}
void VerilatedFst::emitTimeChange(uint64_t timeui) { fstWriterEmitTimeChange(m_fst, timeui); }
void VerilatedFst::emitTimeChange(uint64_t timeui) {
if (!timeui) fstWriterEmitTimeChange(m_fst, timeui);
m_timeui = timeui;
}
VL_ATTR_ALWINLINE
void VerilatedFst::emitTimeChangeMaybe() {
if (VL_UNLIKELY(m_timeui)) {
fstWriterEmitTimeChange(m_fst, m_timeui);
m_timeui = 0;
}
}
//=============================================================================
// Decl
@@ -311,12 +324,14 @@ void VerilatedFst::configure(const VerilatedTraceConfig& config) {
VL_ATTR_ALWINLINE
void VerilatedFstBuffer::emitEvent(uint32_t code) {
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], "1");
}
VL_ATTR_ALWINLINE
void VerilatedFstBuffer::emitBit(uint32_t code, CData newval) {
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], newval ? "1" : "0");
}
@@ -325,6 +340,7 @@ void VerilatedFstBuffer::emitCData(uint32_t code, CData newval, int bits) {
char buf[VL_BYTESIZE];
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
cvtCDataToStr(buf, newval << (VL_BYTESIZE - bits));
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
@@ -333,6 +349,7 @@ void VerilatedFstBuffer::emitSData(uint32_t code, SData newval, int bits) {
char buf[VL_SHORTSIZE];
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
cvtSDataToStr(buf, newval << (VL_SHORTSIZE - bits));
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
@@ -341,6 +358,7 @@ void VerilatedFstBuffer::emitIData(uint32_t code, IData newval, int bits) {
char buf[VL_IDATASIZE];
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
cvtIDataToStr(buf, newval << (VL_IDATASIZE - bits));
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
@@ -349,6 +367,7 @@ void VerilatedFstBuffer::emitQData(uint32_t code, QData newval, int bits) {
char buf[VL_QUADSIZE];
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
cvtQDataToStr(buf, newval << (VL_QUADSIZE - bits));
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
}
@@ -365,10 +384,12 @@ void VerilatedFstBuffer::emitWData(uint32_t code, const WData* newvalp, int bits
cvtEDataToStr(wp, newvalp[--words]);
wp += VL_EDATASIZE;
}
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], m_strbufp);
}
VL_ATTR_ALWINLINE
void VerilatedFstBuffer::emitDouble(uint32_t code, double newval) {
m_owner.emitTimeChangeMaybe();
fstWriterEmitValueChange(m_fst, m_symbolp[code], &newval);
}
+6 -2
View File
@@ -34,6 +34,8 @@ typedef uint32_t vlFstEnumHandle;
class VerilatedFstBuffer;
struct fstWriterContext;
//=============================================================================
// VerilatedFst
// Base class to create a Verilator FST dump
@@ -49,11 +51,12 @@ private:
//=========================================================================
// FST-specific internals
void* m_fst = nullptr;
fstWriterContext* m_fst = nullptr;
std::map<uint32_t, vlFstHandle> m_code2symbol;
std::map<int, vlFstEnumHandle> m_local2fstdtype;
vlFstHandle* m_symbolp = nullptr; // same as m_code2symbol, but as an array
char* m_strbufp = nullptr; // String buffer long enough to hold maxBits() chars
uint64_t m_timeui = 0; // Time to emit, 0 = not needed
bool m_useFstWriterThread = false; // Whether to use the separate FST writer thread
@@ -73,6 +76,7 @@ protected:
// Called when the trace moves forward to a new time point
void emitTimeChange(uint64_t timeui) override;
void emitTimeChangeMaybe();
// Hooks called from VerilatedTrace
bool preFullDump() override { return isOpen(); }
@@ -161,7 +165,7 @@ class VerilatedFstBuffer VL_NOT_FINAL {
VerilatedFst& m_owner; // Trace file owning this buffer. Required by subclasses.
// The FST file handle
void* const m_fst = m_owner.m_fst;
fstWriterContext* const m_fst = m_owner.m_fst;
// code to fstHande map, as an array
const vlFstHandle* const m_symbolp = m_owner.m_symbolp;
// String buffer long enough to hold maxBits() chars
+8
View File
@@ -233,6 +233,14 @@ static inline std::string VL_CVT_N_CSTR(const char* lhsp) VL_PURE {
return lhsp ? std::string{lhsp} : ""s;
}
// Return queue from an unpacked array
template <typename T, std::size_t N_Depth>
static inline VlQueue<T> VL_CVT_UNPACK_TO_Q(const VlUnpacked<T, N_Depth>& q) VL_PURE {
VlQueue<T> ret;
for (size_t i = 0; i < N_Depth; ++i) ret.push_back(q[i]);
return ret;
}
// Return double from lhs (numeric) unsigned
double VL_ITOR_D_W(int lbits, WDataInP const lwp) VL_PURE;
static inline double VL_ITOR_D_I(int, IData lhs) VL_PURE {
+22 -27
View File
@@ -34,28 +34,6 @@ thread_local VlExecutionProfiler::ExecutionTrace VlExecutionProfiler::t_trace;
constexpr const char* const VlExecutionRecord::s_ascii[];
//=============================================================================
// VlPgoProfiler implementation
uint16_t VlExecutionRecord::getcpu() {
#if defined(__linux)
return sched_getcpu(); // TODO: this is a system call. Not exactly cheap.
#elif defined(__APPLE__) && !defined(__arm64__)
uint32_t info[4];
__cpuid_count(1, 0, info[0], info[1], info[2], info[3]);
// info[1] is EBX, bits 24-31 are APIC ID
if ((info[3] & (1 << 9)) == 0) {
return -1; // no APIC on chip
} else {
return (unsigned)info[1] >> 24;
}
#elif defined(_WIN32)
return GetCurrentProcessorNumber();
#else
return 0;
#endif
}
//=============================================================================
// VlExecutionProfiler implementation
@@ -157,15 +135,21 @@ void VlExecutionProfiler::dump(const char* filenamep, uint64_t tickEnd)
VL_DEBUG_IF(VL_DBG_MSGF("+prof+exec writing to '%s'\n", filenamep););
FILE* const fp = std::fopen(filenamep, "w");
if (VL_UNLIKELY(!fp)) { VL_FATAL_MT(filenamep, 0, "", "+prof+exec+file file not writable"); }
if (VL_UNLIKELY(!fp)) VL_FATAL_MT(filenamep, 0, "", "+prof+exec+file file not writable");
// TODO Perhaps merge with verilated_coverage output format, so can
// have a common merging and reporting tool, etc.
fprintf(fp, "VLPROFVERSION 2.1 # Verilator execution profile version 2.1\n");
fprintf(fp, "VLPROFVERSION 2.2 # Verilator execution profile version 2.2\n");
fprintf(fp, "VLPROF arg +verilator+prof+exec+start+%" PRIu64 "\n",
Verilated::threadContextp()->profExecStart());
fprintf(fp, "VLPROF arg +verilator+prof+exec+window+%u\n",
Verilated::threadContextp()->profExecWindow());
std::string numa = "no threads";
if (VlThreadPool* const threadPoolp
= static_cast<VlThreadPool*>(Verilated::threadContextp()->threadPoolp())) {
numa = threadPoolp->numaStatus();
}
fprintf(fp, "VLPROF info numa %s\n", numa.c_str());
// Note that VerilatedContext will by default create as many threads as there are hardware
// processors, but not all of them might be utilized. Report the actual number that has trace
// entries to avoid over-counting.
@@ -206,13 +190,24 @@ void VlExecutionProfiler::dump(const char* filenamep, uint64_t tickEnd)
break;
case VlExecutionRecord::Type::MTASK_BEGIN: {
const auto& payload = er.m_payload.mtaskBegin;
fprintf(fp, " id %u predictStart %u cpu %u\n", payload.m_id,
payload.m_predictStart, payload.m_cpu);
if (payload.m_hierBlock[0] != '\0') {
fprintf(fp, " id %u predictStart %u cpu %u hierBlock %s\n", payload.m_id,
payload.m_predictStart, payload.m_cpu, payload.m_hierBlock);
} else {
fprintf(fp, " id %u predictStart %u cpu %u\n", payload.m_id,
payload.m_predictStart, payload.m_cpu);
}
break;
}
case VlExecutionRecord::Type::MTASK_END: {
const auto& payload = er.m_payload.mtaskEnd;
fprintf(fp, " id %u predictCost %u\n", payload.m_id, payload.m_predictCost);
fprintf(fp, " predictCost %u\n", payload.m_predictCost);
break;
}
case VlExecutionRecord::Type::THREAD_SCHEDULE_WAIT_BEGIN:
case VlExecutionRecord::Type::THREAD_SCHEDULE_WAIT_END: {
const auto& payload = er.m_payload.threadScheduleWait;
fprintf(fp, " cpu %u\n", payload.m_cpu);
break;
}
case VlExecutionRecord::Type::SECTION_PUSH: {
+29 -15
View File
@@ -62,6 +62,8 @@ VL_ATTR_ALWINLINE QData VL_CPU_TICK() {
_VL_FOREACH_APPLY(macro, SECTION_POP) \
_VL_FOREACH_APPLY(macro, MTASK_BEGIN) \
_VL_FOREACH_APPLY(macro, MTASK_END) \
_VL_FOREACH_APPLY(macro, THREAD_SCHEDULE_WAIT_BEGIN) \
_VL_FOREACH_APPLY(macro, THREAD_SCHEDULE_WAIT_END) \
_VL_FOREACH_APPLY(macro, EXEC_GRAPH_BEGIN) \
_VL_FOREACH_APPLY(macro, EXEC_GRAPH_END)
// clang-format on
@@ -90,11 +92,14 @@ class VlExecutionRecord final {
uint32_t m_id; // MTask id
uint32_t m_predictStart; // Time scheduler predicted would start
uint32_t m_cpu; // Executing CPU id
const char* m_hierBlock; // Name of a hier block with this mtask
} mtaskBegin;
struct {
uint32_t m_id; // MTask id
uint32_t m_predictCost; // How long scheduler predicted would take
} mtaskEnd;
struct {
uint32_t m_cpu; // Executing CPU id
} threadScheduleWait;
};
// STATE
@@ -105,8 +110,6 @@ class VlExecutionRecord final {
static_assert(alignof(uint64_t) >= alignof(Payload), "Padding not allowed");
static_assert(alignof(Payload) >= alignof(Type), "Padding not allowed");
static uint16_t getcpu(); // Return currently executing CPU id
public:
// CONSTRUCTOR
VlExecutionRecord() = default;
@@ -117,17 +120,25 @@ public:
m_type = Type::SECTION_PUSH;
}
void sectionPop() { m_type = Type::SECTION_POP; }
void mtaskBegin(uint32_t id, uint32_t predictStart) {
void mtaskBegin(uint32_t id, uint32_t predictStart, const char* hierBlock = "") {
m_payload.mtaskBegin.m_id = id;
m_payload.mtaskBegin.m_predictStart = predictStart;
m_payload.mtaskBegin.m_cpu = getcpu();
m_payload.mtaskBegin.m_cpu = VlOs::getcpu();
m_payload.mtaskBegin.m_hierBlock = hierBlock;
m_type = Type::MTASK_BEGIN;
}
void mtaskEnd(uint32_t id, uint32_t predictCost) {
m_payload.mtaskEnd.m_id = id;
void mtaskEnd(uint32_t predictCost) {
m_payload.mtaskEnd.m_predictCost = predictCost;
m_type = Type::MTASK_END;
}
void threadScheduleWaitBegin() {
m_payload.threadScheduleWait.m_cpu = VlOs::getcpu();
m_type = Type::THREAD_SCHEDULE_WAIT_BEGIN;
}
void threadScheduleWaitEnd() {
m_payload.threadScheduleWait.m_cpu = VlOs::getcpu();
m_type = Type::THREAD_SCHEDULE_WAIT_END;
}
void execGraphBegin() { m_type = Type::EXEC_GRAPH_BEGIN; }
void execGraphEnd() { m_type = Type::EXEC_GRAPH_END; }
};
@@ -214,7 +225,7 @@ public:
// METHODS
VlPgoProfiler() = default;
~VlPgoProfiler() = default;
void write(const char* modelp, const std::string& filename) VL_MT_SAFE;
void write(const char* modelp, const std::string& filename, bool firstHierCall) VL_MT_SAFE;
void addCounter(size_t counter, const std::string& name) {
VL_DEBUG_IF(assert(counter < N_Entries););
m_records.emplace_back(Record{name, counter});
@@ -228,7 +239,8 @@ public:
};
template <std::size_t N_Entries>
void VlPgoProfiler<N_Entries>::write(const char* modelp, const std::string& filename) VL_MT_SAFE {
void VlPgoProfiler<N_Entries>::write(const char* modelp, const std::string& filename,
bool firstHierCall) VL_MT_SAFE {
static VerilatedMutex s_mutex;
const VerilatedLockGuard lock{s_mutex};
@@ -238,7 +250,7 @@ void VlPgoProfiler<N_Entries>::write(const char* modelp, const std::string& file
// each will collect is own data correctly. However when each is
// destroyed we need to get all the data, not keep overwriting and only
// get the last model's data.
static bool s_firstCall = true;
static bool s_firstCall = firstHierCall;
VL_DEBUG_IF(VL_DBG_MSGF("+prof+vlt+file writing to '%s'\n", filename.c_str()););
@@ -246,12 +258,14 @@ void VlPgoProfiler<N_Entries>::write(const char* modelp, const std::string& file
if (VL_UNLIKELY(!fp)) {
VL_FATAL_MT(filename.c_str(), 0, "", "+prof+vlt+file file not writable");
}
s_firstCall = false;
if (s_firstCall) {
// TODO Perhaps merge with verilated_coverage output format, so can
// have a common merging and reporting tool, etc.
fprintf(fp, "// Verilated model profile-guided optimization data dump file\n");
fprintf(fp, "`verilator_config\n");
}
// TODO Perhaps merge with verilated_coverage output format, so can
// have a common merging and reporting tool, etc.
fprintf(fp, "// Verilated model profile-guided optimization data dump file\n");
fprintf(fp, "`verilator_config\n");
s_firstCall = false;
for (const Record& rec : m_records) {
fprintf(fp, "profile_data -model \"%s\" -mtask \"%s\" -cost 64'd%" PRIu64 "\n", modelp,
+20 -9
View File
@@ -282,6 +282,7 @@ std::string parseNestedSelect(const std::string& nested_select_expr,
indices.push_back(idx);
return name;
}
//======================================================================
// VlRandomizer:: Methods
@@ -467,17 +468,27 @@ bool VlRandomizer::parseSolution(std::iostream& f) {
"hex_index contains invalid format");
continue;
}
const long long index = std::stoll(hex_index.substr(start + 2), nullptr, 16);
oss << "[" << index << "]";
std::string trimmed_hex = hex_index.substr(start + 2);
if (trimmed_hex.size() <= 8) { // Small numbers: <= 32 bits
// Convert to decimal and output directly
oss << "[" << std::to_string(std::stoll(trimmed_hex, nullptr, 16)) << "]";
} else { // Large numbers: > 32 bits
// Trim leading zeros and handle empty case
trimmed_hex.erase(0, trimmed_hex.find_first_not_of('0'));
oss << "[" << (trimmed_hex.empty() ? "0" : trimmed_hex) << "]";
}
}
const std::string indexed_name = oss.str();
const auto it = std::find_if(m_arr_vars.begin(), m_arr_vars.end(),
[&indexed_name](const auto& entry) {
return entry.second->m_name == indexed_name;
});
if (it != m_arr_vars.end()) {
const auto iti = std::find_if(m_arr_vars.begin(), m_arr_vars.end(),
[&indexed_name](const auto& entry) {
return entry.second->m_name == indexed_name;
});
if (iti != m_arr_vars.end()) {
std::ostringstream ss;
ss << "#x" << std::hex << std::setw(8) << std::setfill('0') << it->second->m_index;
ss << "#x" << std::hex << std::setw(8) << std::setfill('0')
<< iti->second->m_index;
idx = ss.str();
} else {
VL_FATAL_MT(__FILE__, __LINE__, "randomize",
@@ -498,7 +509,7 @@ void VlRandomizer::clear() { m_constraints.clear(); }
#ifdef VL_DEBUG
void VlRandomizer::dump() const {
for (const auto& var : m_vars) {
VL_PRINTF("Variable (%d): %s\n", var.second->width(), var.second->name());
VL_PRINTF("Variable (%d): %s\n", var.second->width(), var.second->name().c_str());
}
for (const std::string& c : m_constraints) VL_PRINTF("Constraint: %s\n", c.c_str());
}
+275 -84
View File
@@ -27,8 +27,10 @@
#include "verilated.h"
#include <iomanip>
#include <iostream>
#include <ostream>
#include <sstream>
//=============================================================================
// VlRandomExpr and subclasses represent expressions for the constraint solver.
@@ -38,10 +40,10 @@ public:
m_name; // Name of the array variable, including index notation (e.g., arr[2][1])
void* const m_datap; // Reference to the array variable data
const int m_index; // Flattened (1D) index of the array element
const std::vector<size_t> m_indices; // Multi-dimensional indices of the array element
const std::vector<IData> m_indices; // Multi-dimensional indices of the array element
const std::vector<size_t> m_idxWidths; // Multi-dimensional indices' bit widths
ArrayInfo(const std::string& name, void* datap, int index, const std::vector<size_t>& indices,
ArrayInfo(const std::string& name, void* datap, int index, const std::vector<IData>& indices,
const std::vector<size_t>& idxWidths)
: m_name(name)
, m_datap(datap)
@@ -52,21 +54,22 @@ public:
using ArrayInfoMap = std::map<std::string, std::shared_ptr<const ArrayInfo>>;
class VlRandomVar VL_NOT_FINAL {
const char* const m_name; // Variable name
std::string m_name; // Variable name
void* const m_datap; // Reference to variable data
const int m_width; // Variable width in bits
const int m_dimension; //Variable dimension, default is 0
const std::uint32_t m_randModeIdx; // rand_mode index
public:
VlRandomVar(const char* name, int width, void* datap, int dimension, std::uint32_t randModeIdx)
VlRandomVar(const std::string& name, int width, void* datap, int dimension,
std::uint32_t randModeIdx)
: m_name{name}
, m_datap{datap}
, m_width{width}
, m_dimension{dimension}
, m_randModeIdx{randModeIdx} {}
virtual ~VlRandomVar() = default;
const char* name() const { return m_name; }
std::string name() const { return m_name; }
int width() const { return m_width; }
int dimension() const { return m_dimension; }
virtual void* datap(int idx) const { return m_datap; }
@@ -97,7 +100,7 @@ public:
template <typename T>
class VlRandomArrayVarTemplate final : public VlRandomVar {
public:
VlRandomArrayVarTemplate(const char* name, int width, void* datap, int dimension,
VlRandomArrayVarTemplate(const std::string& name, int width, void* datap, int dimension,
std::uint32_t randModeIdx)
: VlRandomVar{name, width, datap, dimension, randModeIdx} {}
void* datap(int idx) const override {
@@ -110,16 +113,31 @@ public:
return nullptr;
}
}
void emitSelect(std::ostream& s, const std::vector<size_t>& indices,
void emitHexs(std::ostream& s, const std::vector<IData>& indices, const size_t bit_width,
size_t idx) const {
for (int j = bit_width - 4; j >= 0; j -= 4) {
s << "0123456789abcdef"[(indices[idx] >> j) & 0xf];
}
}
void emitSelect(std::ostream& s, const std::vector<IData>& indices,
const std::vector<size_t>& idxWidths) const {
for (size_t idx = 0; idx < indices.size(); ++idx) s << "(select ";
const size_t num_indices = idxWidths.size();
size_t wide_size = 0;
for (size_t idx = 0; idx < num_indices; ++idx) s << "(select ";
s << name();
for (size_t idx = 0; idx < indices.size(); ++idx) {
s << " #x";
for (size_t idx = 0; idx < num_indices; ++idx) {
const size_t bit_width = idxWidths[idx];
for (int j = bit_width - 4; j >= 0; j -= 4) {
s << "0123456789abcdef"[(indices[idx] >> j) & 0xf];
s << " #x";
const size_t emit_count = (bit_width > 32) ? (idxWidths[idx] / 32) : 1;
for (size_t i = 0; i < emit_count; ++i) {
emitHexs(s, indices, (bit_width > 32) ? 32 : bit_width, wide_size + i);
}
wide_size += (idxWidths[idx] > 32) ? (idxWidths[idx] / 32) : 1;
s << ")";
}
}
@@ -129,7 +147,7 @@ public:
const std::string indexed_name = name() + std::to_string(i);
const auto it = m_arrVarsRefp->find(indexed_name);
if (it != m_arrVarsRefp->end()) {
const std::vector<size_t>& indices = it->second->m_indices;
const std::vector<IData>& indices = it->second->m_indices;
const std::vector<size_t>& idxWidths = it->second->m_idxWidths;
emitSelect(s, indices, idxWidths);
} else {
@@ -148,7 +166,7 @@ public:
s << "(Array (_ BitVec " << idxWidths[i] << ") ";
}
s << "(_ BitVec " << width() << ")";
for (int i = 0; i < dimension(); ++i) { s << ")"; }
for (int i = 0; i < dimension(); ++i) s << ")";
}
} else {
VL_FATAL_MT(__FILE__, __LINE__, "randomize", "indexed_name not found in m_arr_vars");
@@ -165,7 +183,7 @@ public:
const std::string indexed_name = name() + std::to_string(j);
const auto it = m_arrVarsRefp->find(indexed_name);
if (it != m_arrVarsRefp->end()) {
const std::vector<size_t>& indices = it->second->m_indices;
const std::vector<IData>& indices = it->second->m_indices;
const std::vector<size_t>& idxWidths = it->second->m_idxWidths;
emitSelect(s, indices, idxWidths);
} else {
@@ -176,15 +194,14 @@ public:
};
//=============================================================================
// VlRandomizer is the object holding constraints and variable references.
class VlRandomizer final {
// MEMBERS
std::vector<std::string> m_constraints; // Solver-dependent constraints
std::map<std::string, std::shared_ptr<const VlRandomVar>> m_vars; // Solver-dependent
// variables
ArrayInfoMap m_arr_vars; // Tracks each element in array structures for iteration
std::map<size_t, std::string> seen_values; // Record String Index to avoid conflicts
const VlQueue<CData>* m_randmode; // rand_mode state;
int m_index = 0; // Internal counter for key generation
// PRIVATE METHODS
void randomConstraint(std::ostream& os, VlRNG& rngr, int bits);
@@ -199,76 +216,171 @@ public:
// Finds the next solution satisfying the constraints
bool next(VlRNG& rngr);
// -----------------------------------------------
// --- Process the key for associative array ---
// -----------------------------------------------
// process_key: Handle integral keys (<= 32-bit)
template <typename T_Key>
typename std::enable_if<std::is_integral<T_Key>::value>::type
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
typename std::enable_if<std::is_integral<T_Key>::value && (sizeof(T_Key) <= 4)>::type
process_key(const T_Key& key, std::string& indexed_name, std::vector<size_t>& integral_index,
const std::string& base_name, size_t& idx_width) {
integral_index = static_cast<size_t>(key);
indexed_name = base_name + "[" + std::to_string(integral_index) + "]";
integral_index.push_back(static_cast<size_t>(key));
indexed_name
= base_name + "[" + std::to_string(integral_index[integral_index.size() - 1]) + "]";
idx_width = sizeof(T_Key) * 8;
}
// process_key: Handle integral keys (> 32-bit), split into 2 x 32-bit segments
template <typename T_Key>
typename std::enable_if<std::is_integral<T_Key>::value && (sizeof(T_Key) > 4)>::type
process_key(const T_Key& key, std::string& indexed_name, std::vector<size_t>& integral_index,
const std::string& base_name, size_t& idx_width) {
constexpr size_t segment_bits = 32;
constexpr T_Key mask = (static_cast<T_Key>(1) << segment_bits) - 1;
integral_index.push_back(static_cast<size_t>(key >> segment_bits));
integral_index.push_back(static_cast<size_t>(key & mask));
std::ostringstream hex_stream;
hex_stream << std::hex << key;
std::string index_string = hex_stream.str();
index_string.erase(0, index_string.find_first_not_of('0'));
index_string = index_string.empty() ? "0" : index_string;
indexed_name = base_name + "[" + index_string + "]";
idx_width = sizeof(T_Key) * 8;
}
// process_key: Handle wide keys (VlWide-like), segment is 32-bit per element
template <typename T_Key>
typename std::enable_if<VlIsVlWide<T_Key>::value>::type
process_key(const T_Key& key, std::string& indexed_name, std::vector<size_t>& integral_index,
const std::string& base_name, size_t& idx_width) {
std::ostringstream hex_stream;
for (size_t i = key.size(); i > 0; --i) {
const size_t segment_value = key.at(i - 1);
hex_stream << std::hex << segment_value;
integral_index.push_back(segment_value);
}
std::string index_string = hex_stream.str();
index_string.erase(0, index_string.find_first_not_of('0'));
index_string = index_string.empty() ? "0" : index_string;
indexed_name = base_name + "[" + index_string + "]";
idx_width = key.size() * 32;
}
// process_key: Handle string key, encoded as 128-bit hex
template <typename T_Key>
typename std::enable_if<std::is_same<T_Key, std::string>::value>::type
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
process_key(const T_Key& key, std::string& indexed_name, std::vector<size_t>& integral_index,
const std::string& base_name, size_t& idx_width) {
integral_index = string_to_integral(key);
indexed_name = base_name + "[" + std::to_string(integral_index) + "]";
idx_width = 64; // 64-bit mask
// Convert the input string to its ASCII hexadecimal representation
std::ostringstream oss;
for (unsigned char c : key) {
oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(c);
}
std::string hex_str = oss.str();
// Ensure the hex string is exactly 128 bits (32 hex characters)
hex_str = hex_str.size() > 32 ? hex_str.substr(0, 32)
: std::string(32 - hex_str.size(), '0') + hex_str;
// Split the hex string into 4 segments (32-bit per segment)
integral_index.clear();
for (size_t i = 0; i < hex_str.size(); i += 8) {
integral_index.push_back(std::stoul(hex_str.substr(i, 8), nullptr, 16));
}
indexed_name = base_name + "["
+ (hex_str.find_first_not_of('0') == std::string::npos
? "0"
: hex_str.substr(hex_str.find_first_not_of('0')))
+ "]";
idx_width = 128;
}
// process_key: Unsupported key type fallback
template <typename T_Key>
typename std::enable_if<!std::is_integral<T_Key>::value
&& !std::is_same<T_Key, std::string>::value>::type
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
&& !std::is_same<T_Key, std::string>::value
&& !VlIsVlWide<T_Key>::value>::type
process_key(const T_Key& key, std::string& indexed_name, std::vector<size_t>& integral_index,
const std::string& base_name, size_t& idx_width) {
VL_FATAL_MT(__FILE__, __LINE__, "randomize",
"Unsupported: Only integral and string index of associative array is "
"supported currently.");
}
uint64_t string_to_integral(const std::string& str) {
uint64_t result = 0;
for (char c : str) { result = (result << 8) | static_cast<uint64_t>(c); }
#ifdef VL_DEBUG
if (seen_values.count(result) > 0 && seen_values[result] != str)
VL_WARN_MT(__FILE__, __LINE__, "randomize",
"Conflict detected: Different strings mapped to the same 64-bit index.");
seen_values[result] = str;
#endif
return result;
}
// -----------------------------------------
// --- write_var to register variables ---
// -----------------------------------------
// Register scalar variable (non-struct, basic type)
template <typename T>
void write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
typename std::enable_if<!VlContainsCustomStruct<T>::value, void>::type
write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (m_vars.find(name) != m_vars.end()) return;
// TODO: make_unique once VlRandomizer is per-instance not per-ref
m_vars[name]
= std::make_shared<const VlRandomVar>(name, width, &var, dimension, randmodeIdx);
}
// Register user-defined struct variable by recursively writing members
template <typename T>
void write_var(VlQueue<T>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
typename std::enable_if<VlIsCustomStruct<T>::value, void>::type
write_var(T& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
modifyMembers(var, var.memberIndices(), name);
}
// Register queue of non-struct types
template <typename T>
typename std::enable_if<!VlContainsCustomStruct<T>::value, void>::type
write_var(VlQueue<T>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (m_vars.find(name) != m_vars.end()) return;
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlQueue<T>>>(
name, width, &var, dimension, randmodeIdx);
if (dimension > 0) {
idx = 0;
m_index = 0;
record_arr_table(var, name, dimension, {}, {});
}
}
// Register queue of structs
template <typename T>
typename std::enable_if<VlContainsCustomStruct<T>::value, void>::type
write_var(VlQueue<T>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (dimension > 0) record_struct_arr(var, name, dimension, {}, {});
}
// Register unpacked array of non-struct types
template <typename T, std::size_t N_Depth>
void write_var(VlUnpacked<T, N_Depth>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
typename std::enable_if<!VlContainsCustomStruct<T>::value, void>::type
write_var(VlUnpacked<T, N_Depth>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (m_vars.find(name) != m_vars.end()) return;
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlUnpacked<T, N_Depth>>>(
name, width, &var, dimension, randmodeIdx);
if (dimension > 0) {
idx = 0;
m_index = 0;
record_arr_table(var, name, dimension, {}, {});
}
}
// Register unpacked array of structs
template <typename T, std::size_t N_Depth>
typename std::enable_if<VlContainsCustomStruct<T>::value, void>::type
write_var(VlUnpacked<T, N_Depth>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
if (dimension > 0) record_struct_arr(var, name, dimension, {}, {});
}
// Register associative array of non-struct types
template <typename T_Key, typename T_Value>
void write_var(VlAssocArray<T_Key, T_Value>& var, int width, const char* name, int dimension,
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
@@ -277,46 +389,31 @@ public:
= std::make_shared<const VlRandomArrayVarTemplate<VlAssocArray<T_Key, T_Value>>>(
name, width, &var, dimension, randmodeIdx);
if (dimension > 0) {
idx = 0;
m_index = 0;
record_arr_table(var, name, dimension, {}, {});
}
}
int idx;
std::string generateKey(const std::string& name, int idx) {
if (!name.empty() && name[0] == '\\') {
const size_t space_pos = name.find(' ');
return (space_pos != std::string::npos ? name.substr(0, space_pos) : name)
+ std::to_string(idx);
}
const size_t bracket_pos = name.find('[');
return (bracket_pos != std::string::npos ? name.substr(0, bracket_pos) : name)
+ std::to_string(idx);
// TODO: Register associative array of structs
// ----------------------------------------
// --- Record Arrays: flat and struct ---
// ----------------------------------------
// Record a flat (non-class) element into the array variable table
template <typename T>
typename std::enable_if<!std::is_class<T>::value, void>::type
record_arr_table(T& var, const std::string name, int dimension, std::vector<IData> indices,
std::vector<size_t> idxWidths) {
const std::string key = generateKey(name, m_index);
m_arr_vars[key] = std::make_shared<ArrayInfo>(name, &var, m_index, indices, idxWidths);
++m_index;
}
template <typename T>
void record_arr_table(T& var, const std::string name, int dimension,
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
const std::string key = generateKey(name, idx);
m_arr_vars[key] = std::make_shared<ArrayInfo>(name, &var, idx, indices, idxWidths);
++idx;
}
template <typename T>
void record_arr_table(VlQueue<T>& var, const std::string name, int dimension,
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
if ((dimension > 0) && (var.size() != 0)) {
idxWidths.push_back(32);
for (size_t i = 0; i < var.size(); ++i) {
const std::string indexed_name = name + "[" + std::to_string(i) + "]";
indices.push_back(i);
record_arr_table(var.atWrite(i), indexed_name, dimension - 1, indices, idxWidths);
indices.pop_back();
}
}
}
// Recursively record all elements in an unpacked array
template <typename T, std::size_t N_Depth>
void record_arr_table(VlUnpacked<T, N_Depth>& var, const std::string name, int dimension,
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
std::vector<IData> indices, std::vector<size_t> idxWidths) {
if ((dimension > 0) && (N_Depth != 0)) {
idxWidths.push_back(32);
for (size_t i = 0; i < N_Depth; ++i) {
@@ -328,26 +425,120 @@ public:
}
}
}
// Recursively record all elements in a queue
template <typename T>
void record_arr_table(VlQueue<T>& var, const std::string name, int dimension,
std::vector<IData> indices, std::vector<size_t> idxWidths) {
if ((dimension > 0) && (var.size() != 0)) {
idxWidths.push_back(32);
for (size_t i = 0; i < var.size(); ++i) {
const std::string indexed_name = name + "[" + std::to_string(i) + "]";
indices.push_back(i);
record_arr_table(var.atWrite(i), indexed_name, dimension - 1, indices, idxWidths);
indices.pop_back();
}
}
}
// Recursively record all elements in an associative array
template <typename T_Key, typename T_Value>
void record_arr_table(VlAssocArray<T_Key, T_Value>& var, const std::string name, int dimension,
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
std::vector<IData> indices, std::vector<size_t> idxWidths) {
if ((dimension > 0) && (var.size() != 0)) {
for (auto it = var.begin(); it != var.end(); ++it) {
const T_Key& key = it->first;
const T_Value& value = it->second;
std::string indexed_name;
size_t integral_index;
size_t idx_width;
std::vector<size_t> integral_index;
size_t idx_width = 0;
process_key(key, indexed_name, integral_index, name, idx_width);
// Update indices and widths
idxWidths.push_back(idx_width);
indices.push_back(integral_index);
indices.insert(indices.end(), integral_index.begin(), integral_index.end());
record_arr_table(var.at(key), indexed_name, dimension - 1, indices, idxWidths);
// Cleanup indices and widths
idxWidths.pop_back();
indices.resize(indices.size() - integral_index.size());
}
}
}
// Register a single structArray element via write_var
template <typename T>
typename std::enable_if<VlContainsCustomStruct<T>::value, void>::type
record_struct_arr(T& var, const std::string name, int dimension, std::vector<IData> indices,
std::vector<size_t> idxWidths) {
std::ostringstream oss;
for (size_t i = 0; i < indices.size(); ++i) {
oss << std::hex << static_cast<int>(indices[i]);
if (i < indices.size() - 1) oss << ".";
}
write_var(var, 1ULL, (name + "." + oss.str()).c_str(), 1ULL);
}
// Recursively process VlUnpacked of structs
template <typename T, std::size_t N_Depth>
void record_struct_arr(VlUnpacked<T, N_Depth>& var, const std::string name, int dimension,
std::vector<IData> indices, std::vector<size_t> idxWidths) {
if (dimension > 0 && N_Depth != 0) {
idxWidths.push_back(32);
for (size_t i = 0; i < N_Depth; ++i) {
indices.push_back(i);
record_struct_arr(var.operator[](i), name, dimension - 1, indices, idxWidths);
indices.pop_back();
}
}
}
// Recursively process VlQueue of structs
template <typename T>
void record_struct_arr(VlQueue<T>& var, const std::string name, int dimension,
std::vector<IData> indices, std::vector<size_t> idxWidths) {
if ((dimension > 0) && (var.size() != 0)) {
idxWidths.push_back(32);
for (size_t i = 0; i < var.size(); ++i) {
indices.push_back(i);
record_struct_arr(var.atWrite(i), name, dimension - 1, indices, idxWidths);
indices.pop_back();
}
}
}
// TODO: Add support for associative arrays of structs
// Recursively process associative arrays of structs
// --------------------------
// --- Helper functions ---
// --------------------------
// Helper: Register all members of a user-defined struct
template <typename T, std::size_t... I>
void modifyMembers(T& obj, std::index_sequence<I...>, std::string baseName) {
// Use the indices to access each member via std::get
(void)std::initializer_list<int>{
(write_var(std::get<I>(obj.getMembers(obj)), obj.memberWidth()[I],
(baseName + "." + obj.memberNames()[I]).c_str(), obj.memberDimension()[I]),
0)...};
}
// Helper: Generate unique variable key from name and index
std::string generateKey(const std::string& name, int idx) {
if (!name.empty() && name[0] == '\\') {
const size_t space_pos = name.find(' ');
return (space_pos != std::string::npos ? name.substr(0, space_pos) : name)
+ std::to_string(idx);
}
const size_t bracket_pos = name.find('[');
return (bracket_pos != std::string::npos ? name.substr(0, bracket_pos) : name)
+ std::to_string(idx);
}
void hard(std::string&& constraint);
void clear();
void set_randmode(const VlQueue<CData>& randmode) { m_randmode = &randmode; }
+662
View File
@@ -0,0 +1,662 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// Code available from: https://verilator.org
//
// Copyright 2001-2025 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 Verilated C++ tracing in SAIF format implementation code
///
/// This file must be compiled and linked against all Verilated objects
/// that use --trace-saif.
///
/// Use "verilator --trace-saif" to add this to the Makefile for the linker.
///
//=============================================================================
// clang-format off
#include "verilatedos.h"
#include "verilated.h"
#include "verilated_saif_c.h"
#include <algorithm>
#include <cerrno>
#include <fcntl.h>
#include <string>
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# include <io.h>
#else
# include <unistd.h>
#endif
#ifndef O_LARGEFILE // WIN32 headers omit this
# define O_LARGEFILE 0
#endif
#ifndef O_NONBLOCK // WIN32 headers omit this
# define O_NONBLOCK 0
#endif
#ifndef O_CLOEXEC // WIN32 headers omit this
# define O_CLOEXEC 0
#endif
// clang-format on
//=============================================================================
// Specialization of the generics for this trace format
#define VL_SUB_T VerilatedSaif
#define VL_BUF_T VerilatedSaifBuffer
#include "verilated_trace_imp.h"
#undef VL_SUB_T
#undef VL_BUF_T
//=============================================================================
// VerilatedSaifActivityBit
class VerilatedSaifActivityBit final {
// MEMBERS
bool m_lastVal = false; // Last emitted activity bit value
uint64_t m_highTime = 0; // Total time when bit was high
size_t m_transitions = 0; // Total number of bit transitions
public:
// METHODS
VL_ATTR_ALWINLINE
void aggregateVal(uint64_t dt, bool newVal) {
m_transitions += newVal != m_lastVal ? 1 : 0;
m_highTime += m_lastVal ? dt : 0;
m_lastVal = newVal;
}
// ACCESSORS
VL_ATTR_ALWINLINE bool bitValue() const { return m_lastVal; }
VL_ATTR_ALWINLINE uint64_t highTime() const { return m_highTime; }
VL_ATTR_ALWINLINE uint64_t toggleCount() const { return m_transitions; }
};
//=============================================================================
// VerilatedSaifActivityVar
class VerilatedSaifActivityVar final {
// MEMBERS
uint64_t m_lastTime = 0; // Last time when variable value was updated
VerilatedSaifActivityBit* m_bits; // Pointer to variable bits objects
uint32_t m_width; // Width of variable (in bits)
public:
// CONSTRUCTORS
VerilatedSaifActivityVar(uint32_t width, VerilatedSaifActivityBit* bits)
: m_bits{bits}
, m_width{width} {}
VerilatedSaifActivityVar(VerilatedSaifActivityVar&&) = default;
VerilatedSaifActivityVar& operator=(VerilatedSaifActivityVar&&) = default;
// METHODS
VL_ATTR_ALWINLINE void emitBit(uint64_t time, CData newval);
template <typename DataType>
VL_ATTR_ALWINLINE void emitData(uint64_t time, DataType newval, uint32_t bits) {
static_assert(std::is_integral<DataType>::value,
"The emitted value must be of integral type");
const uint64_t dt = time - m_lastTime;
for (size_t i = 0; i < std::min(m_width, bits); i++) {
m_bits[i].aggregateVal(dt, (newval >> i) & 1);
}
updateLastTime(time);
}
VL_ATTR_ALWINLINE void emitWData(uint64_t time, const WData* newvalp, uint32_t bits);
VL_ATTR_ALWINLINE void updateLastTime(uint64_t val) { m_lastTime = val; }
// ACCESSORS
VL_ATTR_ALWINLINE uint32_t width() const { return m_width; }
VL_ATTR_ALWINLINE VerilatedSaifActivityBit& bit(std::size_t index);
VL_ATTR_ALWINLINE uint64_t lastUpdateTime() const { return m_lastTime; }
private:
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSaifActivityVar);
};
//=============================================================================
// VerilatedSaifActivityScope
class VerilatedSaifActivityScope final {
// MEMBERS
// Absolute path to the scope
std::string m_scopePath;
// Name of the activity scope
std::string m_scopeName;
// Array indices of child scopes
std::vector<std::unique_ptr<VerilatedSaifActivityScope>> m_childScopes{};
// Children signals codes mapped to their names in the current scope
std::vector<std::pair<uint32_t, std::string>> m_childActivities{};
// Parent scope pointer
VerilatedSaifActivityScope* m_parentScope = nullptr;
public:
// CONSTRUCTORS
VerilatedSaifActivityScope(std::string scopePath, std::string name,
VerilatedSaifActivityScope* parentScope = nullptr)
: m_scopePath{std::move(scopePath)}
, m_scopeName{std::move(name)}
, m_parentScope{parentScope} {}
VerilatedSaifActivityScope(VerilatedSaifActivityScope&&) = default;
VerilatedSaifActivityScope& operator=(VerilatedSaifActivityScope&&) = default;
// METHODS
VL_ATTR_ALWINLINE void addChildScope(std::unique_ptr<VerilatedSaifActivityScope> childScope) {
m_childScopes.emplace_back(std::move(childScope));
}
VL_ATTR_ALWINLINE void addActivityVar(uint32_t code, std::string name) {
m_childActivities.emplace_back(code, std::move(name));
}
VL_ATTR_ALWINLINE bool hasParent() const { return m_parentScope; }
// ACCESSORS
VL_ATTR_ALWINLINE const std::string& path() const { return m_scopePath; }
VL_ATTR_ALWINLINE const std::string& name() const { return m_scopeName; }
VL_ATTR_ALWINLINE const std::vector<std::unique_ptr<VerilatedSaifActivityScope>>&
childScopes() const {
return m_childScopes;
}
VL_ATTR_ALWINLINE
const std::vector<std::pair<uint32_t, std::string>>& childActivities() const {
return m_childActivities;
}
VL_ATTR_ALWINLINE VerilatedSaifActivityScope* parentScope() const { return m_parentScope; }
private:
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSaifActivityScope);
};
//=============================================================================
// VerilatedSaifActivityAccumulator
class VerilatedSaifActivityAccumulator final {
// Give access to the private activities
friend class VerilatedSaifBuffer;
friend class VerilatedSaif;
// MEMBERS
// Map of scopes paths to codes of activities inside
std::unordered_map<std::string, std::vector<std::pair<uint32_t, std::string>>>
m_scopeToActivities;
// Map of variables codes mapped to their activity objects
std::unordered_map<uint32_t, VerilatedSaifActivityVar> m_activity;
// Memory pool for signals bits objects
std::vector<std::vector<VerilatedSaifActivityBit>> m_activityArena;
public:
// METHODS
void declare(uint32_t code, const std::string& absoluteScopePath, std::string variableName,
int bits, bool array, int arraynum);
// CONSTRUCTORS
VerilatedSaifActivityAccumulator() = default;
VerilatedSaifActivityAccumulator(VerilatedSaifActivityAccumulator&&) = default;
VerilatedSaifActivityAccumulator& operator=(VerilatedSaifActivityAccumulator&&) = default;
private:
VL_UNCOPYABLE(VerilatedSaifActivityAccumulator);
};
//=============================================================================
//=============================================================================
//=============================================================================
// VerilatedSaifActivityVar implementation
VL_ATTR_ALWINLINE
void VerilatedSaifActivityVar::emitBit(const uint64_t time, const CData newval) {
assert(m_lastTime <= time);
m_bits[0].aggregateVal(time - m_lastTime, newval);
updateLastTime(time);
}
VL_ATTR_ALWINLINE
void VerilatedSaifActivityVar::emitWData(const uint64_t time, const WData* newvalp,
const uint32_t bits) {
assert(m_lastTime <= time);
const uint64_t dt = time - m_lastTime;
for (std::size_t i = 0; i < std::min(m_width, bits); ++i) {
const size_t wordIndex = i / VL_EDATASIZE;
m_bits[i].aggregateVal(dt, (newvalp[wordIndex] >> VL_BITBIT_E(i)) & 1);
}
updateLastTime(time);
}
VerilatedSaifActivityBit& VerilatedSaifActivityVar::bit(const std::size_t index) {
assert(index < m_width);
return m_bits[index];
}
//=============================================================================
//=============================================================================
//=============================================================================
// VerilatedSaifActivityAccumulator implementation
void VerilatedSaifActivityAccumulator::declare(uint32_t code, const std::string& absoluteScopePath,
std::string variableName, int bits, bool array,
int arraynum) {
const size_t block_size = 1024;
if (m_activityArena.empty()
|| m_activityArena.back().size() + bits > m_activityArena.back().capacity()) {
m_activityArena.emplace_back();
m_activityArena.back().reserve(block_size);
}
const size_t bitsIdx = m_activityArena.back().size();
m_activityArena.back().resize(m_activityArena.back().size() + bits);
if (array) {
variableName += '[';
variableName += std::to_string(arraynum);
variableName += ']';
}
m_scopeToActivities[absoluteScopePath].emplace_back(code, variableName);
m_activity.emplace(code, VerilatedSaifActivityVar{static_cast<uint32_t>(bits),
m_activityArena.back().data() + bitsIdx});
}
//=============================================================================
//=============================================================================
//=============================================================================
// VerilatedSaif implementation
VerilatedSaif::VerilatedSaif(void* filep) {
m_activityAccumulators.emplace_back(std::make_unique<VerilatedSaifActivityAccumulator>());
}
void VerilatedSaif::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) {
const VerilatedLockGuard lock{m_mutex};
if (isOpen()) return;
m_filename = filename; // "" is ok, as someone may overload open
m_filep = ::open(m_filename.c_str(),
O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666);
m_isOpen = true;
initializeSaifFileContents();
Super::traceInit();
}
void VerilatedSaif::initializeSaifFileContents() {
printStr("// Generated by verilated_saif\n");
printStr("(SAIFILE\n");
printStr("(SAIFVERSION \"2.0\")\n");
printStr("(DIRECTION \"backward\")\n");
printStr("(PROGRAM_NAME \"Verilator\")\n");
printStr("(DIVIDER / )\n");
printStr("(TIMESCALE ");
printStr(timeResStr());
printStr(")\n");
}
void VerilatedSaif::emitTimeChange(uint64_t timeui) { m_time = timeui; }
VerilatedSaif::~VerilatedSaif() { close(); }
void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
// This function is on the flush() call path
const VerilatedLockGuard lock{m_mutex};
if (!isOpen()) return;
finalizeSaifFileContents();
clearCurrentlyCollectedData();
writeBuffered(true);
::close(m_filep);
m_isOpen = false;
Super::closeBase();
}
void VerilatedSaif::finalizeSaifFileContents() {
printStr("(DURATION ");
printStr(std::to_string(currentTime()));
printStr(")\n");
incrementIndent();
for (const auto& topScope : m_scopes) recursivelyPrintScopes(*topScope);
decrementIndent();
printStr(")\n"); // SAIFILE
}
void VerilatedSaif::recursivelyPrintScopes(const VerilatedSaifActivityScope& scope) {
openInstanceScope(scope.name());
printScopeActivities(scope);
for (const auto& childScope : scope.childScopes()) recursivelyPrintScopes(*childScope);
closeInstanceScope();
}
void VerilatedSaif::openInstanceScope(const std::string& instanceName) {
printIndent();
printStr("(INSTANCE ");
printStr(instanceName);
printStr("\n");
incrementIndent();
}
void VerilatedSaif::closeInstanceScope() {
decrementIndent();
printIndent();
printStr(")\n"); // INSTANCE
}
void VerilatedSaif::printScopeActivities(const VerilatedSaifActivityScope& scope) {
bool anyNetWritten = false;
for (auto& accumulator : m_activityAccumulators) {
anyNetWritten |= printScopeActivitiesFromAccumulatorIfPresent(scope.path(), *accumulator,
anyNetWritten);
}
if (anyNetWritten) closeNetScope();
}
bool VerilatedSaif::printScopeActivitiesFromAccumulatorIfPresent(
const std::string& absoluteScopePath, VerilatedSaifActivityAccumulator& accumulator,
bool anyNetWritten) {
if (accumulator.m_scopeToActivities.count(absoluteScopePath) == 0) return false;
for (const auto& childSignal : accumulator.m_scopeToActivities.at(absoluteScopePath)) {
VerilatedSaifActivityVar& activityVariable = accumulator.m_activity.at(childSignal.first);
anyNetWritten
= printActivityStats(activityVariable, childSignal.second.c_str(), anyNetWritten);
}
return anyNetWritten;
}
void VerilatedSaif::openNetScope() {
printIndent();
printStr("(NET\n");
incrementIndent();
}
void VerilatedSaif::closeNetScope() {
decrementIndent();
printIndent();
printStr(")\n"); // NET
}
bool VerilatedSaif::printActivityStats(VerilatedSaifActivityVar& activity,
const std::string& activityName, bool anyNetWritten) {
for (size_t i = 0; i < activity.width(); ++i) {
VerilatedSaifActivityBit& bit = activity.bit(i);
bit.aggregateVal(currentTime() - activity.lastUpdateTime(), bit.bitValue());
if (!anyNetWritten) {
openNetScope();
anyNetWritten = true;
}
printIndent();
printStr("(");
printStr(activityName);
if (activity.width() > 1) {
printStr("\\[");
printStr(std::to_string(i));
printStr("\\]");
}
// We only have two-value logic so TZ, TX and TB will always be 0
printStr(" (T0 ");
printStr(std::to_string(currentTime() - bit.highTime()));
printStr(") (T1 ");
printStr(std::to_string(bit.highTime()));
printStr(") (TZ 0) (TX 0) (TB 0) (TC ");
printStr(std::to_string(bit.toggleCount()));
printStr("))\n");
}
activity.updateLastTime(currentTime());
return anyNetWritten;
}
void VerilatedSaif::clearCurrentlyCollectedData() {
m_currentScope = nullptr;
m_scopes.clear();
m_activityAccumulators.clear();
}
void VerilatedSaif::printStr(const char* str) {
m_buffer.append(str);
writeBuffered(false);
}
void VerilatedSaif::printStr(const std::string& str) {
m_buffer.append(str);
writeBuffered(false);
}
void VerilatedSaif::writeBuffered(bool force) {
if (VL_UNLIKELY(m_buffer.size() >= WRITE_BUFFER_SIZE || force)) {
if (VL_UNLIKELY(!m_buffer.empty())) {
::write(m_filep, m_buffer.data(), m_buffer.size());
m_buffer = "";
m_buffer.reserve(WRITE_BUFFER_SIZE * 2);
}
}
}
//=============================================================================
// Definitions
void VerilatedSaif::flush() VL_MT_SAFE_EXCLUDES(m_mutex) {
const VerilatedLockGuard lock{m_mutex};
Super::flushBase();
}
void VerilatedSaif::incrementIndent() { m_indent += 1; }
void VerilatedSaif::decrementIndent() { m_indent -= 1; }
void VerilatedSaif::printIndent() {
printStr(std::string(m_indent, ' ')); // Must use () constructor
}
void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType type) {
std::string pname = name;
if (m_prefixStack.back().second == VerilatedTracePrefixType::ROOTIO_MODULE) popPrefix();
if (pname.empty()) {
pname = "$rootio";
type = VerilatedTracePrefixType::ROOTIO_MODULE;
}
if (type != VerilatedTracePrefixType::ARRAY_UNPACKED
&& type != VerilatedTracePrefixType::ARRAY_PACKED) {
std::string scopePath = m_prefixStack.back().first + pname;
std::string scopeName = lastWord(scopePath);
auto newScope = std::make_unique<VerilatedSaifActivityScope>(
std::move(scopePath), std::move(scopeName), m_currentScope);
VerilatedSaifActivityScope* newScopePtr = newScope.get();
if (m_currentScope) {
m_currentScope->addChildScope(std::move(newScope));
} else {
m_scopes.emplace_back(std::move(newScope));
}
m_currentScope = newScopePtr;
}
std::string newPrefix = m_prefixStack.back().first + pname;
if (type != VerilatedTracePrefixType::ARRAY_UNPACKED
&& type != VerilatedTracePrefixType::ARRAY_PACKED) {
newPrefix += ' ';
}
m_prefixStack.emplace_back(newPrefix, type);
}
void VerilatedSaif::popPrefix() {
if (m_prefixStack.back().second != VerilatedTracePrefixType::ARRAY_UNPACKED
&& m_prefixStack.back().second != VerilatedTracePrefixType::ARRAY_PACKED
&& m_currentScope != nullptr) {
m_currentScope = m_currentScope->parentScope();
}
m_prefixStack.pop_back();
}
void VerilatedSaif::declare(const uint32_t code, uint32_t fidx, const char* name,
const char* wirep, const bool array, const int arraynum,
const bool bussed, const int msb, const int lsb) {
assert(m_activityAccumulators.size() > fidx);
VerilatedSaifActivityAccumulator& accumulator = *m_activityAccumulators.at(fidx);
const int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
const std::string hierarchicalName = m_prefixStack.back().first + name;
if (!Super::declCode(code, hierarchicalName, bits)) return;
std::string variableName = lastWord(hierarchicalName);
m_currentScope->addActivityVar(code, variableName);
accumulator.declare(code, m_currentScope->path(), std::move(variableName), bits, array,
arraynum);
}
void VerilatedSaif::declEvent(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum) {
declare(code, fidx, name, "event", array, arraynum, false, 0, 0);
}
void VerilatedSaif::declBit(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum) {
declare(code, fidx, name, "wire", array, arraynum, false, 0, 0);
}
void VerilatedSaif::declBus(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum, const int msb, const int lsb) {
declare(code, fidx, name, "wire", array, arraynum, true, msb, lsb);
}
void VerilatedSaif::declQuad(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum, const int msb, const int lsb) {
declare(code, fidx, name, "wire", array, arraynum, true, msb, lsb);
}
void VerilatedSaif::declArray(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum, const int msb, const int lsb) {
declare(code, fidx, name, "wire", array, arraynum, true, msb, lsb);
}
void VerilatedSaif::declDouble(const uint32_t code, const uint32_t fidx, const char* name,
const int dtypenum, const VerilatedTraceSigDirection,
const VerilatedTraceSigKind, const VerilatedTraceSigType,
const bool array, const int arraynum) {
declare(code, fidx, name, "real", array, arraynum, false, 63, 0);
}
//=============================================================================
// Get/commit trace buffer
VerilatedSaif::Buffer* VerilatedSaif::getTraceBuffer(uint32_t fidx) { return new Buffer{*this}; }
void VerilatedSaif::commitTraceBuffer(VerilatedSaif::Buffer* bufp) { delete bufp; }
//=============================================================================
//=============================================================================
//=============================================================================
// VerilatedSaifBuffer implementation
//=============================================================================
// emit* trace routines
// Note: emit* are only ever called from one place (full* in
// verilated_trace_imp.h, which is included in this file at the top),
// so always inline them.
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitEvent(const uint32_t code) {
// NOP
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitBit(const uint32_t code, const CData newval) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitBit(m_owner.currentTime(), newval);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitCData(const uint32_t code, const CData newval, const int bits) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitData<CData>(m_owner.currentTime(), newval, bits);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitSData(const uint32_t code, const SData newval, const int bits) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitData<SData>(m_owner.currentTime(), newval, bits);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitIData(const uint32_t code, const IData newval, const int bits) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitData<IData>(m_owner.currentTime(), newval, bits);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitQData(const uint32_t code, const QData newval, const int bits) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitData<QData>(m_owner.currentTime(), newval, bits);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitWData(const uint32_t code, const WData* newvalp, const int bits) {
assert(m_owner.m_activityAccumulators.at(m_fidx)->m_activity.count(code)
&& "Activity must be declared earlier");
VerilatedSaifActivityVar& activity
= m_owner.m_activityAccumulators.at(m_fidx)->m_activity.at(code);
activity.emitWData(m_owner.currentTime(), newvalp, bits);
}
VL_ATTR_ALWINLINE
void VerilatedSaifBuffer::emitDouble(const uint32_t code, const double newval) {
// NOP
}
+292
View File
@@ -0,0 +1,292 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// Code available from: https://verilator.org
//
// Copyright 2001-2025 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 Verilated tracing in SAIF format header
///
/// User wrapper code should use this header when creating SAIF traces.
///
//=============================================================================
#ifndef VERILATOR_VERILATED_SAIF_C_H_
#define VERILATOR_VERILATED_SAIF_C_H_
#include "verilated.h"
#include "verilated_trace.h"
#include <string>
#include <unordered_map>
#include <vector>
class VerilatedSaifBuffer;
class VerilatedSaifActivityAccumulator;
class VerilatedSaifActivityScope;
class VerilatedSaifActivityVar;
class VerilatedSaifActivityBit;
//=============================================================================
// VerilatedSaif
// Base class to create a Verilator SAIF dump
// This is an internally used class - see VerilatedSaifC for what to call from applications
class VerilatedSaif VL_NOT_FINAL : public VerilatedTrace<VerilatedSaif, VerilatedSaifBuffer> {
public:
using Super = VerilatedTrace<VerilatedSaif, VerilatedSaifBuffer>;
private:
friend VerilatedSaifBuffer; // Give the buffer access to the private bits
//=========================================================================
// SAIF-specific internals
int m_filep = 0; // File we're writing to
bool m_isOpen = false; // True indicates open file
std::string m_filename; // Filename we're writing to (if open)
std::string m_buffer; // Write data buffer
int m_indent = 0; // Indentation size in spaces
static constexpr size_t WRITE_BUFFER_SIZE = 256 * 1024; // Bytes between write calls
// Currently active scope
VerilatedSaifActivityScope* m_currentScope = nullptr;
// Array of declared scopes
std::vector<std::unique_ptr<VerilatedSaifActivityScope>> m_scopes{};
// Activity accumulators used to store variables statistics over simulation time
std::vector<std::unique_ptr<VerilatedSaifActivityAccumulator>> m_activityAccumulators{};
// Total time of the currently traced simulation
uint64_t m_time = 0;
// Stack of declared scopes combined names
std::vector<std::pair<std::string, VerilatedTracePrefixType>> m_prefixStack{
{"", VerilatedTracePrefixType::SCOPE_MODULE}};
// METHODS
VL_ATTR_ALWINLINE uint64_t currentTime() const { return m_time; }
void initializeSaifFileContents();
void finalizeSaifFileContents();
void recursivelyPrintScopes(const VerilatedSaifActivityScope& scope);
void openInstanceScope(const std::string& instanceName);
void closeInstanceScope();
void printScopeActivities(const VerilatedSaifActivityScope& scope);
bool
printScopeActivitiesFromAccumulatorIfPresent(const std::string& absoluteScopePath,
VerilatedSaifActivityAccumulator& accumulator,
bool anyNetWritten);
void openNetScope();
void closeNetScope();
bool printActivityStats(VerilatedSaifActivityVar& activity, const std::string& activityName,
bool anyNetWritten);
void incrementIndent();
void decrementIndent();
void printIndent();
void printStr(const char* str);
void printStr(const std::string& str);
void writeBuffered(bool force);
void clearCurrentlyCollectedData();
void declare(uint32_t code, uint32_t fidx, const char* name, const char* wirep, bool array,
int arraynum, bool bussed, int msb, int lsb);
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSaif);
protected:
//=========================================================================
// Implementation of VerilatedTrace interface
// Called when the trace moves forward to a new time point
void emitTimeChange(uint64_t timeui) override;
// Hooks called from VerilatedTrace
bool preFullDump() override { return isOpen(); }
bool preChangeDump() override { return isOpen(); }
// Trace buffer management
Buffer* getTraceBuffer(uint32_t fidx) override;
void commitTraceBuffer(Buffer*) override;
// Configure sub-class
void configure(const VerilatedTraceConfig&) override {}
public:
//=========================================================================
// External interface to client code
// CONSTRUCTOR
explicit VerilatedSaif(void* filep = nullptr);
~VerilatedSaif();
// METHODS - All must be thread safe
// Open the file; call isOpen() to see if errors
void open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex);
// Close the file
void close() VL_MT_SAFE_EXCLUDES(m_mutex);
// Flush any remaining data to this file
void flush() VL_MT_SAFE_EXCLUDES(m_mutex);
// Return if file is open
bool isOpen() const VL_MT_SAFE { return m_isOpen; }
//=========================================================================
// Internal interface to Verilator generated code
void pushPrefix(const std::string&, VerilatedTracePrefixType);
void popPrefix();
void declEvent(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum);
void declBit(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum);
void declBus(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum, int msb, int lsb);
void declQuad(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum, int msb, int lsb);
void declArray(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum, int msb, int lsb);
void declDouble(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
VerilatedTraceSigDirection, VerilatedTraceSigKind, VerilatedTraceSigType,
bool array, int arraynum);
};
#ifndef DOXYGEN
// Declare specialization here as it's used in VerilatedSaifC just below
template <>
void VerilatedSaif::Super::dump(uint64_t time);
template <>
void VerilatedSaif::Super::set_time_unit(const char* unitp);
template <>
void VerilatedSaif::Super::set_time_unit(const std::string& unit);
template <>
void VerilatedSaif::Super::set_time_resolution(const char* unitp);
template <>
void VerilatedSaif::Super::set_time_resolution(const std::string& unit);
template <>
void VerilatedSaif::Super::dumpvars(int level, const std::string& hier);
#endif // DOXYGEN
//=============================================================================
// VerilatedSaifBuffer
class VerilatedSaifBuffer VL_NOT_FINAL {
// Give the trace file and sub-classes access to the private bits
friend VerilatedSaif;
friend VerilatedSaif::Super;
friend VerilatedSaif::Buffer;
friend VerilatedSaif::OffloadBuffer;
VerilatedSaif& m_owner; // Trace file owning this buffer. Required by subclasses.
uint32_t m_fidx; // Index of target activity accumulator
// CONSTRUCTORS
explicit VerilatedSaifBuffer(VerilatedSaif& owner)
: m_owner{owner}
, m_fidx{0} {}
explicit VerilatedSaifBuffer(VerilatedSaif& owner, uint32_t fidx)
: m_owner{owner}
, m_fidx{fidx} {}
virtual ~VerilatedSaifBuffer() = default;
//=========================================================================
// Implementation of VerilatedTraceBuffer interface
// Implementations of duck-typed methods for VerilatedTraceBuffer. These are
// called from only one place (the full* methods), so always inline them.
VL_ATTR_ALWINLINE void emitEvent(uint32_t code);
VL_ATTR_ALWINLINE void emitBit(uint32_t code, CData newval);
VL_ATTR_ALWINLINE void emitCData(uint32_t code, CData newval, int bits);
VL_ATTR_ALWINLINE void emitSData(uint32_t code, SData newval, int bits);
VL_ATTR_ALWINLINE void emitIData(uint32_t code, IData newval, int bits);
VL_ATTR_ALWINLINE void emitQData(uint32_t code, QData newval, int bits);
VL_ATTR_ALWINLINE void emitWData(uint32_t code, const WData* newvalp, int bits);
VL_ATTR_ALWINLINE void emitDouble(uint32_t code, double newval);
};
//=============================================================================
// VerilatedSaifC
// Class representing a SAIF dump file in C standalone (no SystemC)
// simulations. Also derived for use in SystemC simulations.
class VerilatedSaifC VL_NOT_FINAL : public VerilatedTraceBaseC {
VerilatedSaif m_sptrace; // Trace file being created
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSaifC);
public:
// Construct the dump. Optional argument is ignored
explicit VerilatedSaifC(void* filep = nullptr)
: m_sptrace{filep} {}
// Destruct, flush, and close the dump
virtual ~VerilatedSaifC() { close(); }
// METHODS - User called
// Return if file is open
bool isOpen() const override VL_MT_SAFE { return m_sptrace.isOpen(); }
// Open a new SAIF file
// This includes a complete header dump each time it is called,
// just as if this object was deleted and reconstructed.
virtual void open(const char* filename) VL_MT_SAFE { m_sptrace.open(filename); }
void rolloverSize(size_t size) VL_MT_SAFE {} // NOP
// Close dump
void close() VL_MT_SAFE {
m_sptrace.close();
modelConnected(false);
}
// Flush dump
void flush() VL_MT_SAFE { m_sptrace.flush(); }
// Write one cycle of dump data
// Call with the current context's time just after eval'ed,
// e.g. ->dump(contextp->time())
void dump(uint64_t timeui) VL_MT_SAFE { m_sptrace.dump(timeui); }
// Write one cycle of dump data - backward compatible and to reduce
// conversion warnings. It's better to use a uint64_t time instead.
void dump(double timestamp) { dump(static_cast<uint64_t>(timestamp)); }
void dump(uint32_t timestamp) { dump(static_cast<uint64_t>(timestamp)); }
void dump(int timestamp) { dump(static_cast<uint64_t>(timestamp)); }
// METHODS - Internal/backward compatible
// \protectedsection
// Set time units (s/ms, defaults to ns)
// Users should not need to call this, as for Verilated models, these
// propagate from the Verilated default timeunit
void set_time_unit(const char* unit) VL_MT_SAFE { m_sptrace.set_time_unit(unit); }
void set_time_unit(const std::string& unit) VL_MT_SAFE { m_sptrace.set_time_unit(unit); }
// Set time resolution (s/ms, defaults to ns)
// Users should not need to call this, as for Verilated models, these
// propagate from the Verilated default timeprecision
void set_time_resolution(const char* unit) VL_MT_SAFE { m_sptrace.set_time_resolution(unit); }
void set_time_resolution(const std::string& unit) VL_MT_SAFE {
m_sptrace.set_time_resolution(unit);
}
// Set variables to dump, using $dumpvars format
// If level = 0, dump everything and hier is then ignored
void dumpvars(int level, const std::string& hier) VL_MT_SAFE {
m_sptrace.dumpvars(level, hier);
}
// Internal class access
VerilatedSaif* spTrace() { return &m_sptrace; }
};
#endif // guard
+56
View File
@@ -0,0 +1,56 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// Copyright 2001-2025 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 Verilated tracing in SAIF format for SystemC header
///
/// User wrapper code should use this header when creating SAIF SystemC traces.
///
/// This class is not threadsafe, as the SystemC kernel is not threadsafe.
///
//=============================================================================
#ifndef VERILATOR_VERILATED_SAIF_SC_H_
#define VERILATOR_VERILATED_SAIF_SC_H_
#include "verilatedos.h"
#include "verilated_saif_c.h"
#include "verilated_sc_trace.h"
//=============================================================================
// VerilatedSaifSc
/// Trace file used to create SAIF dump for SystemC version of Verilated models. It's very similar
/// to its C version (see the class VerilatedSaifC)
class VerilatedSaifSc final : VerilatedScTraceBase, public VerilatedSaifC {
// CONSTRUCTORS
VL_UNCOPYABLE(VerilatedSaifSc);
public:
VerilatedSaifSc() {
spTrace()->set_time_unit(VerilatedScTraceBase::getScTimeUnit());
spTrace()->set_time_resolution(VerilatedScTraceBase::getScTimeResolution());
}
// METHODS
// Override VerilatedSaifC. Must be called after starting simulation.
void open(const char* filename) override VL_MT_SAFE {
VerilatedScTraceBase::checkScElaborationDone();
VerilatedSaifC::open(filename);
}
// METHODS - for SC kernel
// Called from SystemC kernel
void cycle() override { VerilatedSaifC::dump(sc_core::sc_time_stamp().to_double()); }
};
#endif // Guard
+26
View File
@@ -175,6 +175,32 @@ package std;
`endif
endtask
// Two process references are equal if the different classes' containing
// m_process are equal. Can't yet use <=> as the base class template
// comparisons doesn't define <=> as they don't yet require --timing and C++20.
`ifdef VERILATOR_TIMING
`systemc_header_post
template<> template<>
inline bool VlClassRef<`systemc_class_name>::operator==(const VlClassRef<`systemc_class_name>& rhs) const {
if (!m_objp && !rhs.m_objp) return true;
if (!m_objp || !rhs.m_objp) return false;
return m_objp->__PVT__m_process == rhs.m_objp->__PVT__m_process;
};
template<> template<>
inline bool VlClassRef<`systemc_class_name>::operator!=(const VlClassRef<`systemc_class_name>& rhs) const {
if (!m_objp && !rhs.m_objp) return false;
if (!m_objp || !rhs.m_objp) return true;
return m_objp->__PVT__m_process != rhs.m_objp->__PVT__m_process;
};
template<> template<>
inline bool VlClassRef<`systemc_class_name>::operator<(const VlClassRef<`systemc_class_name>& rhs) const {
if (!m_objp && !rhs.m_objp) return false;
if (!m_objp || !rhs.m_objp) return false;
return m_objp->__PVT__m_process < rhs.m_objp->__PVT__m_process;
};
`verilog
`endif
// When really implemented, srandom must operate on the process, but for
// now rely on the srandom() that is automatically generated for all
// classes.
+65 -46
View File
@@ -74,27 +74,41 @@ class VerilatedVarProps VL_NOT_FINAL {
const uint32_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) {
std::vector<VerilatedRange> m_packed; // Packed array ranges
VerilatedRange m_packedDpi; // Flattened packed array range
void initUnpacked(int udims, const int* ulims) {
for (int i = 0; i < 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);
}
}
void initPacked(int pdims, const int* plims) {
int packedSize = 1;
for (int i = 0; i < pdims; ++i) {
const int pleft = plims ? plims[2 * i + 0] : 0;
const int pright = plims ? plims[2 * i + 1] : 0;
m_packed.emplace_back(pleft, pright);
packedSize *= abs(pleft - pright) + 1;
}
if (pdims == 1) {
// Preserve packed array range if the packed component is 1-D
m_packedDpi = m_packed.front();
} else {
m_packedDpi = VerilatedRange{packedSize - 1, 0};
}
}
// CONSTRUCTORS
protected:
friend class VerilatedScope;
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags, int pdims, int udims)
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags, int udims, int pdims)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags{vlflags}
, m_pdims{pdims}
, m_udims{udims} {
initUnpacked(nullptr);
, m_vlflags{vlflags} {
// Only preallocate the ranges
initUnpacked(udims, nullptr);
initPacked(pdims, nullptr);
}
public:
@@ -103,35 +117,29 @@ public:
VerilatedVarProps(VerilatedVarType vltype, int vlflags)
: m_magic{MAGIC}
, m_vltype{vltype}
, m_vlflags(VerilatedVarFlags(vlflags)) // Need () or GCC 4.8 false warning
, m_pdims{0}
, m_udims{0} {}
, m_vlflags(VerilatedVarFlags(vlflags)) {} // Need () or GCC 4.8 false warning
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);
, m_vlflags(VerilatedVarFlags(vlflags)) { // Need () or GCC 4.8 false warning
initUnpacked(udims, ulims);
}
// With packed
class Packed {};
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Packed, int pl, int pr)
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Packed, int pdims, const int* plims)
: 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_vlflags(VerilatedVarFlags(vlflags)) { // Need () or GCC 4.8 false warning
initPacked(pdims, plims);
}
VerilatedVarProps(VerilatedVarType vltype, int vlflags, Unpacked, int udims, const int* ulims,
Packed, int pdims, const int* plims)
: 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);
, m_vlflags(VerilatedVarFlags(vlflags)) { // Need () or GCC 4.8 false warning
initUnpacked(udims, ulims);
initPacked(pdims, plims);
}
~VerilatedVarProps() = default;
@@ -142,41 +150,55 @@ public:
return static_cast<VerilatedVarFlags>(static_cast<int>(m_vlflags) & VLVF_MASK_DIR);
}
uint32_t entSize() const VL_MT_SAFE;
uint32_t entBits() const VL_MT_SAFE {
uint32_t bits = 1;
for (auto it : m_packed) bits *= it.elements();
return bits;
}
bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); }
// DPI compatible C standard layout
bool isDpiCLayout() const { return ((m_vlflags & VLVF_DPI_CLAY) != 0); }
int udims() const VL_MT_SAFE { return m_udims; }
int dims() const { return m_pdims + m_udims; }
const VerilatedRange& packed() const VL_MT_SAFE { return m_packed; }
const VerilatedRange& unpacked() const { return m_unpacked[0]; }
// DPI accessors
int udims() const VL_MT_SAFE { return m_unpacked.size(); }
int pdims() const VL_MT_SAFE { return m_packed.size(); }
int dims() const VL_MT_SAFE { return pdims() + udims(); }
const std::vector<VerilatedRange>& packedRanges() const VL_MT_SAFE { return m_packed; }
const std::vector<VerilatedRange>& unpackedRanges() const VL_MT_SAFE { return m_unpacked; }
const VerilatedRange* range(int dim) const VL_MT_SAFE {
if (dim < udims())
return &m_unpacked[dim];
else if (dim < dims())
return &m_packed[dim - udims()];
else
return nullptr;
}
// DPI accessors (with packed dimensions flattened!)
int left(int dim) const VL_MT_SAFE {
return dim == 0 ? m_packed.left()
return dim == 0 ? m_packedDpi.left()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].left()
: 0;
}
int right(int dim) const VL_MT_SAFE {
return dim == 0 ? m_packed.right()
return dim == 0 ? m_packedDpi.right()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].right()
: 0;
}
int low(int dim) const VL_MT_SAFE {
return dim == 0 ? m_packed.low()
return dim == 0 ? m_packedDpi.low()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].low()
: 0;
}
int high(int dim) const VL_MT_SAFE {
return dim == 0 ? m_packed.high()
return dim == 0 ? m_packedDpi.high()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].high()
: 0;
}
int increment(int dim) const {
return dim == 0 ? m_packed.increment()
return dim == 0 ? m_packedDpi.increment()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].increment()
: 0;
}
int elements(int dim) const VL_MT_SAFE {
return dim == 0 ? m_packed.elements()
return dim == 0 ? m_packedDpi.elements()
: VL_LIKELY(dim >= 1 && dim <= udims()) ? m_unpacked[dim - 1].elements()
: 0;
}
@@ -208,8 +230,7 @@ public:
bool magicOk() const { return m_propsp->magicOk(); }
VerilatedVarType vltype() const { return m_propsp->vltype(); }
bool isDpiStdLayout() const { return m_propsp->isDpiCLayout(); }
const VerilatedRange& packed() const { return m_propsp->packed(); }
const VerilatedRange& unpacked() const { return m_propsp->unpacked(); }
int entBits() const { return m_propsp->entBits(); }
int udims() const VL_MT_SAFE { return m_propsp->udims(); }
int left(int dim) const VL_MT_SAFE { return m_propsp->left(dim); }
int right(int dim) const VL_MT_SAFE { return m_propsp->right(dim); }
@@ -236,8 +257,8 @@ protected:
friend class VerilatedScope;
// CONSTRUCTORS
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)}
VerilatedVarFlags vlflags, int udims, int pdims, bool isParam)
: VerilatedVarProps{vltype, vlflags, udims, pdims}
, m_datap{datap}
, m_namep{namep}
, m_isParam{isParam} {}
@@ -246,8 +267,6 @@ public:
~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; }
};
+146 -1
View File
@@ -26,6 +26,8 @@
#include "verilated_threads.h"
#include <cstdio>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
@@ -100,10 +102,153 @@ void VlWorkerThread::startWorker(VlWorkerThread* workerp, VerilatedContext* cont
// VlThreadPool
VlThreadPool::VlThreadPool(VerilatedContext* contextp, unsigned nThreads) {
for (unsigned i = 0; i < nThreads; ++i) m_workers.push_back(new VlWorkerThread{contextp});
for (unsigned i = 0; i < nThreads; ++i) {
m_workers.push_back(new VlWorkerThread{contextp});
m_unassignedWorkers.push(i);
}
m_numaStatus = numaAssign();
}
VlThreadPool::~VlThreadPool() {
// Each ~WorkerThread will wait for its thread to exit.
for (auto& i : m_workers) delete i;
}
bool VlThreadPool::isNumactlRunning() {
// We assume if current thread is CPU-masked, then under numactl, otherwise not.
// This shows that numactl is visible through the affinity mask
#if defined(__linux) || defined(CPU_ZERO) // Linux-like; assume we have pthreads etc
const unsigned num_cpus = std::thread::hardware_concurrency();
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
const int rc = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (rc != 0) return true; // Error; assuming returning true is the least-damage option
for (unsigned c = 0; c < std::min(num_cpus, static_cast<unsigned>(CPU_SETSIZE)); ++c) {
if (!CPU_ISSET(c, &cpuset)) return true;
}
#endif
return false;
}
std::string VlThreadPool::numaAssign() {
#if defined(__linux) || defined(CPU_ZERO) // Linux-like; assume we have pthreads etc
// If not under numactl, make a reasonable processor affinity selection
if (isNumactlRunning()) return "running under numactl"; // User presumably set affinity
const int num_threads = static_cast<int>(m_workers.size());
const int num_proc = static_cast<int>(std::thread::hardware_concurrency());
if (num_threads < 2) return "too few threads";
if (num_threads > num_proc) return "too many threads";
// Read CPU info.
// Uncertain if any modern system has gaps in the processor id (Solaris
// did), but just in case use vectors instead of processor number math.
//
// Currently ignoring socket number "physical id".
// If processor numbers are sequential on sockets, algorithm works out ok.
// If processor numbers are strided on sockets, algorithm also works out ok.
std::ifstream is{"/proc/cpuinfo"};
if (VL_UNLIKELY(!is)) return "%Warning: no /proc/cpuinfo";
std::vector<int> unassigned_processors; // Processors to assign in sorted order
std::map<int, int> processor_core;
std::multimap<int, int> core_processors;
std::set<int> cores;
int processor = -1;
int core = -1;
while (!is.eof()) {
std::string line;
std::getline(is, line);
static std::string::size_type pos = line.find(":");
int number = -1;
if (pos != std::string::npos) number = atoi(line.c_str() + pos + 1);
if (line.compare(0, std::strlen("processor"), "processor") == 0) {
processor = number;
core = -1;
} else if (line.compare(0, std::strlen("core id"), "core id") == 0) {
core = number;
// std::cout << "p" << processor << " socket " << socket << " c" << core << std::endl;
cores.emplace(core);
processor_core[processor] = core;
core_processors.emplace(core, processor);
unassigned_processors.push_back(processor);
}
}
// Start scheduling on the current CPU + 1.
// This will help to land on the same socket as current CPU, and also
// help make sure that different processes have different masks (when
// num_threads is not a common-factor of the processor count).
std::sort(unassigned_processors.begin(), unassigned_processors.end());
{
const int on_cpu = sched_getcpu(); // TODO: this is a system call. Not exactly cheap.
bool hit = false;
std::vector<int> new_front;
std::vector<int> new_back;
for (const int processor : unassigned_processors) {
if (hit) {
new_front.push_back(processor);
} else {
new_back.push_back(processor);
}
if (processor == on_cpu) hit = true;
}
unassigned_processors = new_front;
unassigned_processors.insert(unassigned_processors.end(), new_back.begin(),
new_back.end());
}
// If less threads than cores, we can schedule per-core
const bool core_per_thread = num_threads <= cores.size();
// Compute core mapping
std::multimap<int, int> thread_processors;
{
std::set<int> assigned_processors;
int thread = 0;
for (const int processor : unassigned_processors) {
// Find free processor, the current thread can use that
if (assigned_processors.find(processor) != assigned_processors.end()) continue;
assigned_processors.emplace(processor);
thread_processors.emplace(thread, processor);
if (core_per_thread) {
// Also include all other processors same core,
// so that another thread doesn't land on different processor in same core
const int core = processor_core[processor];
const auto bounds = core_processors.equal_range(core);
for (auto it{bounds.first}; it != bounds.second; ++it) {
if (assigned_processors.find(it->second) != assigned_processors.end())
continue;
if (it->second == processor) continue;
thread_processors.emplace(thread, it->second);
assigned_processors.emplace(it->second);
}
}
// Prepare for next loop
thread = (thread + 1) % num_threads;
}
}
// Set affinity
std::string status = "assigned ";
for (int thread = 0; thread < num_threads; ++thread) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
const auto bounds = thread_processors.equal_range(thread);
for (auto it{bounds.first}; it != bounds.second; ++it) {
if (it != bounds.first) status += ',';
status += std::to_string(it->second);
CPU_SET(it->second, &cpuset);
}
status += ";";
const int rc = pthread_setaffinity_np(m_workers[thread]->m_cthread.native_handle(),
sizeof(cpu_set_t), &cpuset);
if (rc != 0) return "%Warning: pthread_setaffinity_np failed";
}
// std::cout << "Status: " << status << std::endl;
return status;
#else
return "non-supported host OS";
#endif
}
+29 -9
View File
@@ -30,18 +30,10 @@
#include <atomic>
#include <condition_variable>
#include <set>
#include <stack>
#include <thread>
#include <vector>
// clang-format off
#if defined(__linux)
# include <sched.h> // For sched_getcpu()
#endif
#if defined(__APPLE__) && !defined(__arm64__)
# include <cpuid.h> // For __cpuid_count()
#endif
// clang-format on
class VlExecutionProfiler;
class VlThreadPool;
@@ -155,6 +147,10 @@ private:
VL_UNCOPYABLE(VlWorkerThread);
protected:
friend class VlThreadPool;
const std::thread& cthread() const { return m_cthread; }
public:
// CONSTRUCTORS
explicit VlWorkerThread(VerilatedContext* contextp);
@@ -205,6 +201,13 @@ class VlThreadPool final : public VerilatedVirtualBase {
// MEMBERS
std::vector<VlWorkerThread*> m_workers; // our workers
mutable VerilatedMutex m_mutex; // Guards indexes of unassigned workers
// Indexes of unassigned workers
std::stack<size_t> m_unassignedWorkers VL_GUARDED_BY(m_mutex);
// For sequentially generating task IDs to avoid shadowing
std::atomic<unsigned> m_assignedTasks{0};
std::string m_numaStatus; // Status of NUMA assignment
public:
// CONSTRUCTORS
// Construct a thread pool with 'nThreads' dedicated threads. The thread
@@ -214,7 +217,21 @@ public:
~VlThreadPool() override;
// METHODS
size_t assignWorkerIndex() {
const VerilatedLockGuard lock{m_mutex};
assert(!m_unassignedWorkers.empty());
const size_t index = m_unassignedWorkers.top();
m_unassignedWorkers.pop();
return index;
}
void freeWorkerIndexes(std::vector<size_t>& indexes) {
const VerilatedLockGuard lock{m_mutex};
for (size_t index : indexes) m_unassignedWorkers.push(index);
indexes.clear();
}
unsigned assignTaskIndex() { return m_assignedTasks++; }
int numThreads() const { return static_cast<int>(m_workers.size()); }
std::string numaStatus() const { return m_numaStatus; }
VlWorkerThread* workerp(int index) {
assert(index >= 0);
assert(index < static_cast<int>(m_workers.size()));
@@ -223,6 +240,9 @@ public:
private:
VL_UNCOPYABLE(VlThreadPool);
static bool isNumactlRunning();
std::string numaAssign();
};
#endif
+35 -8
View File
@@ -184,8 +184,11 @@ public:
// Word at given 'wordIndex'
uint64_t word(size_t wordIndex) const { return m_flags[wordIndex]; }
// Set specified flag to given value
void set(size_t index, bool value) {
// Set specified word to given value
void setWord(size_t wordIndex, uint64_t value) { m_flags[wordIndex] = value; }
// Set specified bit to given value
void setBit(size_t index, bool value) {
uint64_t& w = m_flags[index / 64];
const size_t bitIndex = index % 64;
w &= ~(1ULL << bitIndex);
@@ -451,6 +454,7 @@ struct VlWide final {
// METHODS
const EData& at(size_t index) const { return m_storage[index]; }
EData& at(size_t index) { return m_storage[index]; }
size_t size() const { return N_Words; }
WData* data() { return &m_storage[0]; }
const WData* data() const { return &m_storage[0]; }
bool operator<(const VlWide<N_Words>& rhs) const {
@@ -504,6 +508,12 @@ public:
VlQueue& operator=(VlQueue&&) = default;
bool operator==(const VlQueue& rhs) const { return m_deque == rhs.m_deque; }
bool operator!=(const VlQueue& rhs) const { return m_deque != rhs.m_deque; }
bool operator<(const VlQueue& rhs) const {
for (int index = 0; index < m_deque.size(); ++index) {
if (m_deque[index] < rhs.m_deque[index]) return true;
}
return false;
}
// Standard copy constructor works. Verilog: assoca = assocb
// Also must allow conversion from a different N_MaxSize queue
@@ -611,11 +621,13 @@ public:
T_Value& atWriteAppend(int32_t index) {
// cppcheck-suppress variableScope
static thread_local T_Value t_throwAway;
if (VL_UNLIKELY(index < 0 || index > m_deque.size())) {
if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) {
if (index == m_deque.size()) {
push_back(atDefault());
return m_deque[index];
}
t_throwAway = atDefault();
return t_throwAway;
} else if (VL_UNLIKELY(index == m_deque.size())) {
push_back(atDefault());
}
return m_deque[index];
}
@@ -914,6 +926,9 @@ std::string VL_TO_STRING(const VlQueue<T_Value, N_MaxSize>& obj) {
return obj.to_string();
}
template <typename T_Value, size_t N_MaxSize>
struct VlContainsCustomStruct<VlQueue<T_Value, N_MaxSize>> : VlContainsCustomStruct<T_Value> {};
//===================================================================
// Verilog associative array container
// There are no multithreaded locks on this; the base variable must
@@ -947,7 +962,7 @@ public:
VlAssocArray& operator=(VlAssocArray&&) = default;
bool operator==(const VlAssocArray& rhs) const { return m_map == rhs.m_map; }
bool operator!=(const VlAssocArray& rhs) const { return m_map != rhs.m_map; }
bool operator<(const VlAssocArray& rhs) const { return m_map < rhs.m_map; }
// METHODS
T_Value& atDefault() { return m_defaultValue; }
const T_Value& atDefault() const { return m_defaultValue; }
@@ -1249,6 +1264,9 @@ std::string VL_TO_STRING(const VlAssocArray<T_Key, T_Value>& obj) {
return obj.to_string();
}
template <typename T_Key, typename T_Value>
struct VlContainsCustomStruct<VlAssocArray<T_Key, T_Value>> : VlContainsCustomStruct<T_Key> {};
template <typename T_Key, typename T_Value>
void VL_READMEM_N(bool hex, int bits, const std::string& filename,
VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
@@ -1312,7 +1330,7 @@ public:
WData* data() { return &m_storage[0]; }
const WData* data() const { return &m_storage[0]; }
std::size_t size() const { return N_Depth; }
constexpr std::size_t size() const { return N_Depth; }
// To fit C++14
template <std::size_t N_CurrentDimension = 0, typename U = T_Value>
int find_length(int dimension, std::false_type) const {
@@ -1350,7 +1368,7 @@ public:
}
T_Value& operator[](size_t index) { return m_storage[index]; }
const T_Value& operator[](size_t index) const { return m_storage[index]; }
constexpr const T_Value& operator[](size_t index) const { return m_storage[index]; }
// *this != that, which might be used for change detection/trigger computation, but avoid
// operator overloading in VlUnpacked for safety in other contexts.
@@ -1363,6 +1381,12 @@ public:
bool neq(const T_Value that[N_Depth]) const { return neq(*this, that); }
void assign(const T_Value that[N_Depth]) { std::copy_n(that, N_Depth, m_storage); }
void operator=(const T_Value that[N_Depth]) { assign(that); }
bool operator<(const VlUnpacked<T_Value, N_Depth>& that) const {
for (int index = 0; index < N_Depth; ++index) {
if (m_storage[index] < that.m_storage[index]) return true;
}
return false;
}
// inside (set membership operator)
bool inside(const T_Value& value) const {
@@ -1573,6 +1597,9 @@ std::string VL_TO_STRING(const VlUnpacked<T_Value, N_Depth>& obj) {
return obj.to_string();
}
template <typename T, int N>
struct VlContainsCustomStruct<VlUnpacked<T, N>> : VlContainsCustomStruct<T> {};
//===================================================================
// Helper to apply the given indices to a target expression
+23 -6
View File
@@ -15,9 +15,9 @@
/// \brief Verilated C++ tracing in VCD format implementation code
///
/// This file must be compiled and linked against all Verilated objects
/// that use --trace.
/// that use --trace-vcd.
///
/// Use "verilator --trace" to add this to the Makefile for the linker.
/// Use "verilator --trace-vcd" to add this to the Makefile for the linker.
///
//=============================================================================
@@ -100,6 +100,8 @@ VerilatedVcd::VerilatedVcd(VerilatedVcdFile* filep) {
m_wrBufp = new char[m_wrChunkSize * 8];
m_wrFlushp = m_wrBufp + m_wrChunkSize * 6;
m_writep = m_wrBufp;
m_wrTimeBeginp = nullptr;
m_wrTimeEndp = nullptr;
}
void VerilatedVcd::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) {
@@ -187,10 +189,19 @@ bool VerilatedVcd::preChangeDump() {
}
void VerilatedVcd::emitTimeChange(uint64_t timeui) {
printStr("#");
const std::string str = std::to_string(timeui);
printStr(str.c_str());
printStr("\n");
// Remember pointers when last emitted time stamp; if last output was
// timestamp backup and overwrite it.
// This is faster then checking on every signal change if time needs to
// be emitted. Note buffer flushes may still emit a rare duplicate.
if (m_wrTimeEndp == m_writep) m_writep = m_wrTimeBeginp;
m_wrTimeBeginp = m_writep;
{
printStr("#");
const std::string str = std::to_string(timeui);
printStr(str.c_str());
printStr("\n");
}
m_wrTimeEndp = m_writep;
}
VerilatedVcd::~VerilatedVcd() {
@@ -257,6 +268,10 @@ void VerilatedVcd::bufferResize(size_t minsize) {
m_wrBufp = new char[m_wrChunkSize * 8];
std::memcpy(m_wrBufp, oldbufp, m_writep - oldbufp);
m_writep = m_wrBufp + (m_writep - oldbufp);
if (m_wrTimeBeginp) {
m_wrTimeBeginp = m_wrBufp + (m_wrTimeBeginp - oldbufp);
m_wrTimeEndp = m_wrBufp + (m_wrTimeEndp - oldbufp);
}
m_wrFlushp = m_wrBufp + m_wrChunkSize * 6;
VL_DO_CLEAR(delete[] oldbufp, oldbufp = nullptr);
}
@@ -293,6 +308,8 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
// Reset buffer
m_writep = m_wrBufp;
m_wrTimeBeginp = nullptr;
m_wrTimeEndp = nullptr;
}
//=============================================================================
+2
View File
@@ -55,6 +55,8 @@ private:
char* m_wrBufp; // Output buffer
char* m_wrFlushp; // Output buffer flush trigger location
char* m_writep; // Write pointer into output buffer
char* m_wrTimeBeginp = nullptr; // Write pointer for last time dump
char* m_wrTimeEndp = nullptr; // Write pointer for last time dump
size_t m_wrChunkSize; // Output buffer size
size_t m_maxSignalBytes = 0; // Upper bound on number of bytes a single signal can generate
uint64_t m_wroteBytes = 0; // Number of bytes written to this file
+1033 -344
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -474,6 +474,7 @@ using ssize_t = uint32_t; ///< signed size_t; returned from read()
#ifndef VL_VALUE_STRING_MAX_WORDS
#define VL_VALUE_STRING_MAX_WORDS 64 ///< Max size in words of String conversion operation
#endif
#define VL_VALUE_STRING_MAX_CHARS (VL_VALUE_STRING_MAX_WORDS) * 4
//=========================================================================
// Base macros
@@ -631,7 +632,12 @@ namespace VlOs {
/// Get environment variable
extern std::string getenvStr(const std::string& envvar,
const std::string& defaultValue) VL_MT_SAFE;
extern uint64_t memUsageBytes() VL_MT_SAFE; ///< Return memory usage in bytes, or 0 if unknown
/// Return currently executing processor number; may do an OS call underneath so slow
extern uint16_t getcpu() VL_MT_SAFE;
/// Return memory usage in bytes, or 0 if unknown
extern uint64_t memUsageBytes() VL_MT_SAFE;
// Internal: Record CPU time, starting point on construction, and current delta from that
class DeltaCpuTime final {
+29
View File
@@ -31,6 +31,13 @@
# include <processthreadsapi.h> // GetProcessTimes
# include <psapi.h> // GetProcessMemoryInfo
#endif
#if defined(__linux)
# include <sched.h> // For sched_getcpu()
#endif
#if defined(__APPLE__) && !defined(__arm64__)
# include <cpuid.h> // For __cpuid_count()
#endif
// clang-format on
namespace VlOs {
@@ -72,6 +79,28 @@ double DeltaWallTime::gettime() VL_MT_SAFE {
#endif
}
//=============================================================================
// Vlos::getcpu implementation
uint16_t getcpu() VL_MT_SAFE {
#if defined(__linux)
return sched_getcpu(); // TODO: this is a system call. Not exactly cheap.
#elif defined(__APPLE__) && !defined(__arm64__)
uint32_t info[4];
__cpuid_count(1, 0, info[0], info[1], info[2], info[3]);
// info[1] is EBX, bits 24-31 are APIC ID
if ((info[3] & (1 << 9)) == 0) {
return 0; // no APIC on chip
} else {
return (unsigned)info[1] >> 24;
}
#elif defined(_WIN32)
return GetCurrentProcessorNumber();
#else
return 0;
#endif
}
//=========================================================================
// VlOs::memUsageBytes implementation
+31
View File
@@ -0,0 +1,31 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Code available from: https://verilator.org
//
// Copyright 2009-2025 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 Verilated user tf_routines
///
/// This file contains routines to interface user VPI/PLI C++ code with
/// Verilator. Traditionally the veriuser.h code has been used for only
/// tf_ routines, which verilator does not implement, so this file is
/// empty.
///
/// User code relying on tf_ routines should migrate to VPI (vpi_user.h) or
/// DPI (svdpi.h) routines.
///
/// This file is only provided for backwards compatibility for applications
/// which include veriuser.h even though they use only vpi_ or dpi_
/// routines.
///
//=========================================================================
// Intentionally empty, see above.
+1 -1
View File
@@ -90,7 +90,7 @@ def process():
print()
print("You may now want to clean up spelling, and commit:")
print(" (cd docs ; make spelling)")
print(" (cd docs ; make spelling | grep -vi 'writing output')")
print(" git ci -am 'Commentary: Changes update'")
print()
+241
View File
@@ -0,0 +1,241 @@
#!/usr/bin/env python3
# pylint: disable=C0114,C0115,C0116,R0902,R0903,R0912,R0915,W0719,W0718
######################################################################
#
# Copyright 2025 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
import argparse
import re
SUCCESS_CODE = 0
FAILURE_CODE = 1
INSTANCE_TYPE = "INSTANCE"
NET_LIST_TYPE = "NET"
SIGNAL_TYPE = "SIGNAL"
EOF_ERROR = "Unexpected EOF"
def saif_assert(expression, message):
if not expression:
raise Exception(message)
def saif_error(message):
raise Exception(message)
class SAIFSignalBit:
name: str
high_time: int
low_time: int
transitions: int
def __init__(self, name):
self.name = name
self.high_time = 0
self.low_time = 0
self.transitions = 0
class SAIFInstance:
def __init__(self, scope_name):
self.scope_name = scope_name
self.parent_instance = None
self.nets = {}
self.child_instances = {}
class SAIFToken:
def __init__(self, token):
self.token = token
self.type = ''
self.value = ''
class SAIFParser:
def __init__(self):
self.token_stack = []
# For parsing simplicity
self.token_stack.append(SAIFToken('saif_root'))
self.current_instance = None
self.has_saifile_header = False
self.direction = ''
self.saif_version = ''
self.top_instances = {}
self.duration = 0
self.divider = ''
self.timescale = ''
def parse(self, saif_filename):
file_contents = ''
with open(saif_filename, 'r', encoding="utf8") as saif_file:
content = saif_file.readlines()
filtered_lines = [line for line in content if not line.strip().startswith('//')]
file_contents = ''.join(filtered_lines)
tokens = file_contents.replace('(', ' ( ').replace(')', ' ) ').split()
num_of_tokens = len(tokens)
index = 0
while index < num_of_tokens:
token = tokens[index]
index += 1
if token == '(':
self.token_stack.append(SAIFToken(token))
self.token_stack[-1].type = self.token_stack[-2].type
self.token_stack[-1].value = self.token_stack[-2].value
continue
if token == ')':
if self.token_stack[-1].type == INSTANCE_TYPE:
self.current_instance = self.current_instance.parent_instance
self.token_stack.pop()
continue
if re.match(r'SAIFILE', token):
self.has_saifile_header = True
continue
if re.match(r'DIRECTION', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
self.direction = tokens[index].replace('\"', '')
index += 1
continue
if re.match(r'SAIFVERSION', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
self.saif_version = tokens[index].replace('\"', '')
index += 1
continue
if re.match(r'DESIGN|DATE|VENDOR|PROGRAM_NAME|VERSION', token):
# NOP, only skip value
saif_assert(index < num_of_tokens, EOF_ERROR)
index += 1
continue
if re.match(r'DIVIDER', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
self.divider = tokens[index]
index += 1
continue
if re.match(r'TIMESCALE', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
self.timescale = tokens[index]
index += 1
continue
if re.match(r'DURATION', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
self.duration = tokens[index]
index += 1
continue
if re.match(r'INSTANCE', token):
saif_assert(index < num_of_tokens, EOF_ERROR)
instance_name = tokens[index]
index += 1
self.token_stack[-1].type = INSTANCE_TYPE
self.token_stack[-1].value = instance_name
instance = SAIFInstance(instance_name)
if self.current_instance is None:
self.top_instances[instance_name] = instance
else:
self.current_instance.child_instances[instance_name] = instance
instance.parent_instance = self.current_instance
self.current_instance = instance
continue
if re.match(r'NET', token):
self.token_stack[-1].type = NET_LIST_TYPE
continue
if re.match(r'T1', token):
net_name = self.token_stack[-1].value
saif_assert(index < num_of_tokens, EOF_ERROR)
self.current_instance.nets[net_name].high_time = tokens[index]
index += 1
continue
if re.match(r'T0', token):
net_name = self.token_stack[-1].value
saif_assert(index < num_of_tokens, EOF_ERROR)
self.current_instance.nets[net_name].low_time = tokens[index]
index += 1
continue
if re.match(r'TC', token):
net_name = self.token_stack[-1].value
saif_assert(index < num_of_tokens, EOF_ERROR)
self.current_instance.nets[net_name].transitions = tokens[index]
index += 1
continue
if re.match(r'TZ|TX|TB|TG|IG|IK', token):
# NOP, only skip value
index += 1
continue
if self.token_stack[-2].type == NET_LIST_TYPE:
self.token_stack[-1].type = SIGNAL_TYPE
self.token_stack[-1].value = token
self.current_instance.nets[token] = SAIFSignalBit(token)
saif_assert(self.has_saifile_header, "SAIF file doesn't contain a SAIFILE keyword")
saif_assert(self.direction == "backward",
f"SAIF file doesn't have a valid/compatible direction: {self.direction}")
saif_assert(self.saif_version == "2.0",
f"SAIF file doesn't have a valid/compatible version: {self.saif_version}")
# Only 'saif_root' token should be left
saif_assert(len(self.token_stack) == 1, "Incorrect nesting of scopes")
def compare_saif_instances(first: SAIFInstance, second: SAIFInstance):
if len(first.nets) != len(second.nets):
saif_error(f"Number of nets doesn't match in {first.scope_name}: "
f"{len(first.nets)} != {len(second.nets)}")
for signal_name, saif_signal in first.nets.items():
if signal_name not in second.nets:
saif_error(f"Signal {signal_name} doesn't exist in the second object\n")
other_signal = second.nets[signal_name]
if (saif_signal.high_time != other_signal.high_time
or saif_signal.low_time != other_signal.low_time
or saif_signal.transitions != other_signal.transitions):
saif_error("Incompatible signal bit parameters in "
f"{signal_name}\n")
if len(first.child_instances) != len(second.child_instances):
saif_error(f"Number of child instances doesn't match in {first.scope_name}: "
f"{len(first.child_instances)} != {len(second.child_instances)}")
for instance_name, instance in first.child_instances.items():
if instance_name not in second.child_instances:
saif_error(f"Instance {instance_name} doesn't exist in the second object\n")
compare_saif_instances(instance, second.child_instances[instance_name])
def compare_saif_contents(first_file: str, second_file: str):
"""Test if second SAIF file has the same values as the first"""
first_saif = SAIFParser()
first_saif.parse(first_file)
second_saif = SAIFParser()
second_saif.parse(second_file)
if first_saif.duration != second_saif.duration:
saif_error("Duration of trace doesn't match: "
f"{first_saif.duration} != {second_saif.duration}")
if first_saif.divider != second_saif.divider:
saif_error(f"Dividers don't match: {first_saif.divider} != {second_saif.divider}")
if first_saif.timescale != second_saif.timescale:
saif_error(f"Timescale doesn't match: {first_saif.timescale} != {second_saif.timescale}")
if len(first_saif.top_instances) != len(second_saif.top_instances):
saif_error("Number of top instances doesn't match: "
f"{len(first_saif.top_instances)} != {len(second_saif.top_instances)}")
for top_instance_name, top_instance in first_saif.top_instances.items():
if top_instance_name not in second_saif.top_instances:
saif_error(f"Top instance {top_instance_name} missing in other SAIF")
compare_saif_instances(top_instance, second_saif.top_instances[top_instance_name])
return SUCCESS_CODE
parser = argparse.ArgumentParser(allow_abbrev=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""verilator_saif_diff checks if two SAIF files are logically-identical. It returns first encountered difference as output.
Run as:
cd $VERILATOR_ROOT
nodist/code_coverage --first example.saif --second other.saif""")
parser.add_argument('--first', action='store', help='First SAIF file')
parser.add_argument('--second', action='store', help='Second SAIF file')
parser.set_defaults(stop=True)
args = parser.parse_args()
try:
compare_saif_contents(args.first, args.second)
except Exception as error:
print(error)
+4
View File
@@ -85,6 +85,7 @@ set(HEADERS
V3EmitCMain.h
V3EmitCMake.h
V3EmitMk.h
V3EmitMkJson.h
V3EmitV.h
V3EmitXml.h
V3Error.h
@@ -177,6 +178,7 @@ set(HEADERS
V3Trace.h
V3TraceDecl.h
V3Tristate.h
V3Udp.h
V3Undriven.h
V3UniqueNames.h
V3Unknown.h
@@ -246,6 +248,7 @@ set(COMMON_SOURCES
V3EmitCPch.cpp
V3EmitCSyms.cpp
V3EmitMk.cpp
V3EmitMkJson.cpp
V3EmitV.cpp
V3EmitXml.cpp
V3Error.cpp
@@ -324,6 +327,7 @@ set(COMMON_SOURCES
V3TraceDecl.cpp
V3Tristate.cpp
V3TSP.cpp
V3Udp.cpp
V3Undriven.cpp
V3Unknown.cpp
V3Unroll.cpp
+2
View File
@@ -253,6 +253,7 @@ RAW_OBJS_PCH_ASTNOMT = \
V3EmitCModel.o \
V3EmitCSyms.o \
V3EmitMk.o \
V3EmitMkJson.o \
V3EmitXml.o \
V3ExecGraph.o \
V3Expand.o \
@@ -310,6 +311,7 @@ RAW_OBJS_PCH_ASTNOMT = \
V3Trace.o \
V3TraceDecl.o \
V3Tristate.o \
V3Udp.o \
V3Undriven.o \
V3Unknown.o \
V3Unroll.o \
+14 -12
View File
@@ -239,7 +239,7 @@ public:
// Make a new AstActive sensitive to the given sentree and return it
AstActive* makeActive(FileLine* const fl, AstSenTree* const senTreep) {
auto* const activep = new AstActive{fl, "", senTreep};
AstActive* const activep = new AstActive{fl, "", senTreep};
activep->sensesStorep(activep->sensesp());
addActive(activep);
return activep;
@@ -314,7 +314,7 @@ class ActiveLatchCheckVisitor final : public VNVisitorConst {
void visit(AstVarRef* nodep) override {
const AstVar* const varp = nodep->varp();
if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()
&& !varp->isFuncLocalSticky()) {
&& !varp->isFuncLocalSticky() && !varp->lifetime().isAutomatic()) {
m_graph.addAssignment(nodep);
}
}
@@ -349,7 +349,7 @@ public:
class ActiveDlyVisitor final : public VNVisitor {
public:
enum CheckType : uint8_t { CT_SEQ, CT_COMB, CT_INITIAL };
enum CheckType : uint8_t { CT_SEQ, CT_COMB, CT_INITIAL, CT_SUSPENDABLE };
private:
// MEMBERS
@@ -358,7 +358,7 @@ private:
// VISITORS
void visit(AstAssignDly* nodep) override {
// Non-blocking assignments are OK in sequential processes
if (m_check == CT_SEQ) return;
if (m_check == CT_SEQ || m_check == CT_SUSPENDABLE) return;
// Issue appropriate warning
if (m_check == CT_INITIAL) {
@@ -477,10 +477,8 @@ class ActiveVisitor final : public VNVisitor {
AstActive* const wantactivep
= !m_clockedProcess ? m_namer.getSpecialActive<AstSenItem::Combo>(nodep->fileline())
: oldsensesp ? m_namer.getActive(nodep->fileline(), oldsensesp)
: m_namer.getSpecialActive<AstSenItem::Initial>(nodep->fileline());
// Delete sensitivity list
if (oldsensesp) VL_DO_DANGLING(oldsensesp->deleteTree(), oldsensesp);
// Clocked, no sensitivity lists, it's a suspendable, put it in initial
: m_namer.getSpecialActive<AstSenItem::Initial>(nodep->fileline());
// Move node to new active
nodep->unlinkFrBack();
@@ -488,10 +486,14 @@ class ActiveVisitor final : public VNVisitor {
// Warn and convert any delayed assignments
{
ActiveDlyVisitor{nodep, m_clockedProcess ? ActiveDlyVisitor::CT_SEQ
: ActiveDlyVisitor::CT_COMB};
ActiveDlyVisitor{nodep, !m_clockedProcess ? ActiveDlyVisitor::CT_COMB
: oldsensesp ? ActiveDlyVisitor::CT_SEQ
: ActiveDlyVisitor::CT_SUSPENDABLE};
}
// Delete sensitivity list
if (oldsensesp) VL_DO_DANGLING(oldsensesp->deleteTree(), oldsensesp);
// check combinational processes for latches
if (!m_clockedProcess || kwd == VAlwaysKwd::ALWAYS_LATCH) {
const ActiveLatchCheckVisitor latchvisitor{nodep, kwd == VAlwaysKwd::ALWAYS_LATCH};
@@ -570,8 +572,8 @@ class ActiveVisitor final : public VNVisitor {
m_clockedProcess = true;
if (nodep->edgeType() != VEdgeType::ET_CHANGED) m_allChanged = false;
if (const auto* const dtypep = nodep->sensp()->dtypep()) {
if (const auto* const basicp = dtypep->basicp()) {
if (const AstNodeDType* const dtypep = nodep->sensp()->dtypep()) {
if (const AstBasicDType* const basicp = dtypep->basicp()) {
if (basicp->isEvent()) nodep->edgeType(VEdgeType::ET_EVENT);
}
}
+14 -13
View File
@@ -143,7 +143,7 @@ class AssertVisitor final : public VNVisitor {
}
}
AstSampled* newSampledExpr(AstNodeExpr* nodep) {
const auto sampledp = new AstSampled{nodep->fileline(), nodep};
AstSampled* const sampledp = new AstSampled{nodep->fileline(), nodep};
sampledp->dtypeFrom(nodep);
return sampledp;
}
@@ -153,7 +153,7 @@ class AssertVisitor final : public VNVisitor {
nodep->findUInt64DType()};
v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorNumVarp);
}
const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorNumVarp, access};
AstVarRef* const varrefp = new AstVarRef{nodep->fileline(), m_monitorNumVarp, access};
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
return varrefp;
}
@@ -163,7 +163,7 @@ class AssertVisitor final : public VNVisitor {
nodep->findBitDType()};
v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorOffVarp);
}
const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorOffVarp, access};
AstVarRef* const varrefp = new AstVarRef{nodep->fileline(), m_monitorOffVarp, access};
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
return varrefp;
}
@@ -528,14 +528,15 @@ class AssertVisitor final : public VNVisitor {
replaceDisplay(nodep, "%%Fatal");
} else if (nodep->displayType() == VDisplayType::DT_MONITOR) {
nodep->displayType(VDisplayType::DT_DISPLAY);
const auto fl = nodep->fileline();
FileLine* const fl = nodep->fileline();
AstNode* monExprsp = nodep->fmtp()->exprsp();
AstSenItem* monSenItemsp = nullptr;
while (monExprsp) {
if (AstNodeVarRef* varrefp = VN_CAST(monExprsp, NodeVarRef)) {
AstSenItem* const senItemp
= new AstSenItem(fl, VEdgeType::ET_CHANGED,
new AstVarRef{fl, varrefp->varp(), VAccess::READ});
= new AstSenItem{fl, VEdgeType::ET_CHANGED,
// Clone so get VarRef or VarXRef as needed
varrefp->cloneTree(false)};
if (!monSenItemsp) {
monSenItemsp = senItemp;
} else {
@@ -547,8 +548,8 @@ class AssertVisitor final : public VNVisitor {
AstSenTree* const monSenTree = new AstSenTree{fl, monSenItemsp};
const auto monNum = ++m_monitorNum;
// Where $monitor was we do "__VmonitorNum = N;"
const auto newsetp = new AstAssign{fl, newMonitorNumVarRefp(nodep, VAccess::WRITE),
new AstConst{fl, monNum}};
AstAssign* const newsetp = new AstAssign{
fl, newMonitorNumVarRefp(nodep, VAccess::WRITE), new AstConst{fl, monNum}};
nodep->replaceWith(newsetp);
// Add "always_comb if (__VmonitorOn && __VmonitorNum==N) $display(...);"
AstNode* const stmtsp = nodep;
@@ -565,14 +566,14 @@ class AssertVisitor final : public VNVisitor {
} else if (nodep->displayType() == VDisplayType::DT_STROBE) {
nodep->displayType(VDisplayType::DT_DISPLAY);
// Need one-shot
const auto fl = nodep->fileline();
const auto varp
FileLine* const fl = nodep->fileline();
AstVar* const varp
= new AstVar{fl, VVarType::MODULETEMP, "__Vstrobe" + cvtToStr(m_modStrobeNum++),
nodep->findBitDType()};
m_modp->addStmtsp(varp);
// Where $strobe was we do "__Vstrobe = '1;"
const auto newsetp = new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitTrue{}}};
AstAssign* const newsetp = new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitTrue{}}};
nodep->replaceWith(newsetp);
// Add "always_comb if (__Vstrobe) begin $display(...); __Vstrobe = '0; end"
AstNode* const stmtsp = nodep;
@@ -586,7 +587,7 @@ class AssertVisitor final : public VNVisitor {
}
}
void visit(AstMonitorOff* nodep) override {
const auto newp
AstAssign* const newp
= new AstAssign{nodep->fileline(), newMonitorOffVarRefp(nodep, VAccess::WRITE),
new AstConst{nodep->fileline(), AstConst::BitTrue{}, nodep->off()}};
nodep->replaceWith(newp);
+5 -5
View File
@@ -95,10 +95,10 @@ private:
if (const AstVarRef* varrefp = VN_CAST(nodep, VarRef)) {
if (varp == varrefp->varp()) nodep->replaceWith(exprp->cloneTree(false));
}
replaceVarRefsWithExprRecurse(nodep->op1p(), varp, exprp);
replaceVarRefsWithExprRecurse(nodep->op2p(), varp, exprp);
replaceVarRefsWithExprRecurse(nodep->op3p(), varp, exprp);
replaceVarRefsWithExprRecurse(nodep->op4p(), varp, exprp);
if (AstNode* const refp = nodep->op1p()) replaceVarRefsWithExprRecurse(refp, varp, exprp);
if (AstNode* const refp = nodep->op2p()) replaceVarRefsWithExprRecurse(refp, varp, exprp);
if (AstNode* const refp = nodep->op3p()) replaceVarRefsWithExprRecurse(refp, varp, exprp);
if (AstNode* const refp = nodep->op4p()) replaceVarRefsWithExprRecurse(refp, varp, exprp);
}
AstPropSpec* substitutePropertyCall(AstPropSpec* nodep) {
if (AstFuncRef* const funcrefp = VN_CAST(nodep->propp(), FuncRef)) {
@@ -295,7 +295,7 @@ private:
popp->makeStmt()});
}
} else {
nodep->v3fatal("Invalid direction");
nodep->v3fatalSrc("Invalid direction");
}
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
}
+26 -15
View File
@@ -64,10 +64,12 @@ std::ostream& operator<<(std::ostream& os, VNType rhs);
const std::shared_ptr<const string> VSelfPointerText::s_emptyp = std::make_shared<string>("");
const std::shared_ptr<const string> VSelfPointerText::s_thisp = std::make_shared<string>("this");
string VSelfPointerText::replaceThis(bool useSelfForThis, const string& text) {
return useSelfForThis ? VString::replaceWord(text, "this", "vlSelf") : text;
}
string VSelfPointerText::protect(bool useSelfForThis, bool protect) const {
const string& sp
= useSelfForThis ? VString::replaceWord(asString(), "this", "vlSelf") : asString();
return VIdProtect::protectWordsIf(sp, protect);
return VIdProtect::protectWordsIf(replaceThis(useSelfForThis, asString()), protect);
}
//######################################################################
@@ -196,6 +198,11 @@ string AstNode::prettyName(const string& namein) VL_PURE {
pos += 7;
continue;
}
if (0 == std::strncmp(pos, "__Viftop", 8)) {
pretty += "";
pos += 8;
continue;
}
if (pos[0] == '_' && pos[1] == '_' && pos[2] == '0' && std::isxdigit(pos[3])
&& std::isxdigit(pos[4])) {
char value = 0;
@@ -223,7 +230,7 @@ string AstNode::vpiName(const string& namein) {
// we change that identifier to an escaped identifier, wrapping it with '\' and ' '
// as specified in LRM 23.6
string name = namein;
if (0 == namein.substr(0, 7).compare("__SYM__")) { name = namein.substr(7); }
if (0 == namein.substr(0, 7).compare("__SYM__")) name = namein.substr(7);
string pretty;
pretty.reserve(name.length());
bool inEscapedIdent = false;
@@ -797,13 +804,7 @@ void AstNode::swapWith(AstNode* bp) {
AstNode* AstNode::cloneTreeIter(bool needPure) {
// private: Clone single node and children
if (VL_UNLIKELY(needPure && !isPure())) {
this->v3warn(SIDEEFFECT,
"Expression side effect may be mishandled\n"
<< this->warnMore()
<< "... Suggest use a temporary variable in place of this expression");
// this->v3fatalSrc("cloneTreePure debug backtrace"); // Comment in to debug where caused
}
if (needPure) purityCheck();
AstNode* const newp = this->clone();
if (this->m_op1p) newp->op1p(this->m_op1p->cloneTreeIterList(needPure));
if (this->m_op2p) newp->op2p(this->m_op2p->cloneTreeIterList(needPure));
@@ -850,6 +851,16 @@ AstNode* AstNode::cloneTree(bool cloneNextLink, bool needPure) {
return newp;
}
void AstNode::purityCheck() {
if (VL_UNLIKELY(!isPure())) {
this->v3warn(SIDEEFFECT,
"Expression side effect may be mishandled\n"
<< this->warnMore()
<< "... Suggest use a temporary variable in place of this expression");
// this->v3fatalSrc("cloneTreePure debug backtrace"); // Comment in to debug where caused
}
}
//======================================================================
// Delete
@@ -1331,7 +1342,7 @@ void AstNode::dumpTreeFile(const string& filename, bool doDump) {
{ // Write log & close
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> logsp{V3File::new_ofstream(filename)};
if (logsp->fail()) v3fatal("Can't write " << filename);
if (logsp->fail()) v3fatal("Can't write file: " << filename);
*logsp << "Verilator Tree Dump (format 0x3900) from <e" << std::dec << editCountLast();
*logsp << "> to <e" << std::dec << editCountGbl() << ">\n";
if (editCountGbl() == editCountLast() && ::dumpTreeLevel() < 9) {
@@ -1376,7 +1387,7 @@ void AstNode::dumpTreeJsonFile(const string& filename, bool doDump) {
if (!doDump) return;
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> treejsonp{V3File::new_ofstream(filename)};
if (treejsonp->fail()) v3fatal("Can't write " << filename);
if (treejsonp->fail()) v3fatal("Can't write file: " << filename);
dumpTreeJson(*treejsonp);
*treejsonp << '\n';
}
@@ -1385,7 +1396,7 @@ void AstNode::dumpJsonMetaFileGdb(const char* filename) { dumpJsonMetaFile(filen
void AstNode::dumpJsonMetaFile(const string& filename) {
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> treejsonp{V3File::new_ofstream(filename)};
if (treejsonp->fail()) v3fatalStatic("Can't write " << filename);
if (treejsonp->fail()) v3fatalStatic("Can't write file: " << filename);
*treejsonp << '{';
FileLine::fileNameNumMapDumpJson(*treejsonp);
*treejsonp << ',';
@@ -1399,7 +1410,7 @@ void AstNode::dumpTreeDotFile(const string& filename, bool doDump) {
if (doDump) {
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> treedotp{V3File::new_ofstream(filename)};
if (treedotp->fail()) v3fatal("Can't write " << filename);
if (treedotp->fail()) v3fatal("Can't write file: " << filename);
*treedotp << "digraph vTree{\n";
*treedotp << "\tgraph\t[label=\"" << filename + ".dot"
<< "\",\n";
+5
View File
@@ -1686,6 +1686,7 @@ public:
bool isVlSym() const { return m_strp->find("vlSymsp") != string::npos; }
bool hasThis() const { return m_strp == s_thisp || VString::startsWith(*m_strp, "this"); }
string protect(bool useSelfForThis, bool protect) const;
static string replaceThis(bool useSelfForThis, const string& text);
const std::string& asString() const { return *m_strp; }
bool operator==(const VSelfPointerText& other) const { return *m_strp == *other.m_strp; }
};
@@ -2077,6 +2078,7 @@ private:
string instanceStr() const;
public:
void purityCheck();
static void relinkOneLink(AstNode*& pointpr, AstNode* newp);
// cppcheck-suppress functionConst
static void debugTreeChange(const AstNode* nodep, const char* prefix, int lineno, bool next);
@@ -2358,6 +2360,7 @@ public:
AstNodeDType* findBitDType() const { return findBasicDType(VBasicDTypeKwd::LOGIC); }
AstNodeDType* findDoubleDType() const { return findBasicDType(VBasicDTypeKwd::DOUBLE); }
AstNodeDType* findStringDType() const { return findBasicDType(VBasicDTypeKwd::STRING); }
AstNodeDType* findSigned8DType() const { return findBasicDType(VBasicDTypeKwd::BYTE); }
AstNodeDType* findSigned32DType() const { return findBasicDType(VBasicDTypeKwd::INTEGER); }
AstNodeDType* findUInt32DType() const { return findBasicDType(VBasicDTypeKwd::UINT32); }
AstNodeDType* findUInt64DType() const { return findBasicDType(VBasicDTypeKwd::UINT64); }
@@ -2484,6 +2487,8 @@ public:
virtual bool isGateOptimizable() const { return !isTimingControl(); }
// GateDedupable is a slightly larger superset of GateOptimzable (eg, AstNodeIf)
virtual bool isGateDedupable() const { return isGateOptimizable(); }
// Whether the node can be used in expression coverage
virtual bool isExprCoverageEligible() const { return isGateDedupable(); }
// Else creates output or exits, etc, not unconsumed
virtual bool isOutputter() { return false; }
// Else a AstTime etc which output can't be predicted from input
+4 -2
View File
@@ -188,8 +188,9 @@ bool AstVarRef::sameNode(const AstVarRef* samep) const {
if (varScopep()) {
return (varScopep() == samep->varScopep() && access() == samep->access());
} else {
return (selfPointer() == samep->selfPointer() && varp()->name() == samep->varp()->name()
&& access() == samep->access());
return (selfPointer() == samep->selfPointer()
&& classOrPackagep() == samep->classOrPackagep() && access() == samep->access()
&& (varp() && samep->varp() && varp()->name() == samep->varp()->name()));
}
}
bool AstVarRef::sameNoLvalue(AstVarRef* samep) const {
@@ -197,6 +198,7 @@ bool AstVarRef::sameNoLvalue(AstVarRef* samep) const {
return (varScopep() == samep->varScopep());
} else {
return (selfPointer() == samep->selfPointer()
&& classOrPackagep() == samep->classOrPackagep()
&& (!selfPointer().isEmpty() || !samep->selfPointer().isEmpty())
&& varp()->name() == samep->varp()->name());
}
+47 -23
View File
@@ -50,7 +50,8 @@ protected:
private:
// METHODS
const AstNodeDType* skipRefIterp(bool skipConst, bool skipEnum) const VL_MT_STABLE;
const AstNodeDType* skipRefIterp(bool skipConst, bool skipEnum,
bool assertOn = true) const VL_MT_STABLE;
protected:
// METHODS
@@ -78,6 +79,15 @@ public:
return const_cast<AstNodeDType*>(
static_cast<const AstNodeDType*>(this)->skipRefIterp(true, true));
}
// (Slow) Recurse over MemberDType|ParamTypeDType|RefDType|ConstDType|EnumDType to other type,
// Returns null if not resolved
const AstNodeDType* skipRefOrNullp() const VL_MT_STABLE {
return skipRefIterp(true, true, false);
}
AstNodeDType* skipRefOrNullp() VL_MT_STABLE {
return const_cast<AstNodeDType*>(
static_cast<const AstNodeDType*>(this)->skipRefIterp(true, true, false));
}
// (Slow) Recurse over MemberDType|ParamTypeDType|RefDType|EnumDType to ConstDType
const AstNodeDType* skipRefToConstp() const { return skipRefIterp(false, true); }
AstNodeDType* skipRefToConstp() {
@@ -110,15 +120,7 @@ public:
// Iff has second dtype, set as generic node function
virtual void virtRefDType2p(AstNodeDType* nodep) {}
// Assignable equivalence. Calls skipRefToNonRefp() during comparisons.
bool similarDType(const AstNodeDType* samep) const {
const AstNodeDType* nodep = this;
nodep = nodep->skipRefToNonRefp();
samep = samep->skipRefToNonRefp();
if (nodep == samep) return true;
if (nodep->type() != samep->type()) return false;
return nodep->similarDTypeNode(samep);
}
bool similarDType(const AstNodeDType* samep) const;
// Iff has a non-null subDTypep(), as generic node function
virtual AstNodeDType* subDTypep() const VL_MT_STABLE { return nullptr; }
virtual bool isFourstate() const;
@@ -155,7 +157,7 @@ public:
bool generic() const VL_MT_SAFE { return m_generic; }
void generic(bool flag) { m_generic = flag; }
std::pair<uint32_t, uint32_t> dimensions(bool includeBasic);
uint32_t arrayUnpackedElements(); // 1, or total multiplication of all dimensions
uint32_t arrayUnpackedElements() const; // 1, or total multiplication of all dimensions
static int uniqueNumInc() { return ++s_uniqueNum; }
const char* charIQWN() const {
return (isString() ? "N" : isWide() ? "W" : isQuad() ? "Q" : "I");
@@ -230,6 +232,7 @@ class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType {
const int m_uniqueNum;
bool m_packed;
bool m_isFourstate = false; // V3Width computes
bool m_constrainedRand = false; // True if struct has constraint expression
protected:
AstNodeUOrStructDType(VNType t, FileLine* fl, VSigning numericUnpack)
@@ -244,7 +247,8 @@ protected:
, m_name(other.m_name)
, m_uniqueNum(uniqueNumInc())
, m_packed(other.m_packed)
, m_isFourstate(other.m_isFourstate) {}
, m_isFourstate(other.m_isFourstate)
, m_constrainedRand(false) {}
public:
ASTGEN_MEMBERS_AstNodeUOrStructDType;
@@ -284,6 +288,8 @@ public:
VNumRange declRange() const VL_MT_STABLE { return VNumRange{hi(), lo()}; }
AstNodeModule* classOrPackagep() const { return m_classOrPackagep; }
void classOrPackagep(AstNodeModule* classpackagep) { m_classOrPackagep = classpackagep; }
bool isConstrainedRand() { return m_constrainedRand; }
void markConstrainedRand(bool flag) { m_constrainedRand = flag; }
};
// === Concrete node types =====================================================
@@ -518,7 +524,7 @@ public:
AstCDType(FileLine* fl, const string& name)
: ASTGEN_SUPER_CDType(fl)
, m_name{name} {
this->dtypep(this);
dtypep(this);
}
public:
@@ -558,8 +564,8 @@ public:
AstClassRefDType(FileLine* fl, AstClass* classp, AstPin* paramsp)
: ASTGEN_SUPER_ClassRefDType(fl)
, m_classp{classp} {
this->dtypep(this);
this->addParamsp(paramsp);
dtypep(this);
addParamsp(paramsp);
}
ASTGEN_MEMBERS_AstClassRefDType;
// METHODS
@@ -567,7 +573,11 @@ public:
const AstClassRefDType* const asamep = VN_DBG_AS(samep, ClassRefDType);
return (m_classp == asamep->m_classp && m_classOrPackagep == asamep->m_classOrPackagep);
}
bool similarDTypeNode(const AstNodeDType* samep) const override { return sameNode(samep); }
bool similarDTypeNode(const AstNodeDType* samep) const override {
// Doesn't need to compare m_classOrPackagep
const AstClassRefDType* const asamep = VN_DBG_AS(samep, ClassRefDType);
return m_classp == asamep->m_classp;
}
void dump(std::ostream& str = std::cout) const override;
void dumpJson(std::ostream& str = std::cout) const override;
void dumpSmall(std::ostream& str) const override;
@@ -905,12 +915,14 @@ class AstMemberDType final : public AstNodeDType {
string m_name; // Name of variable
string m_tag; // Holds the string of the verilator tag -- used in XML output.
int m_lsb = -1; // Within this level's packed struct, the LSB of the first bit of the member
bool m_constrainedRand = false;
// UNSUP: int m_randType; // Randomization type (IEEE)
public:
AstMemberDType(FileLine* fl, const string& name, VFlagChildDType, AstNodeDType* dtp,
AstNode* valuep)
: ASTGEN_SUPER_MemberDType(fl)
, m_name{name} {
, m_name{name}
, m_constrainedRand(false) {
childDTypep(dtp); // Only for parser
this->valuep(valuep);
dtypep(nullptr); // V3Width will resolve
@@ -918,13 +930,16 @@ public:
}
AstMemberDType(FileLine* fl, const string& name, AstNodeDType* dtp)
: ASTGEN_SUPER_MemberDType(fl)
, m_name{name} {
, m_name{name}
, m_constrainedRand(false) {
UASSERT(dtp, "AstMember created with no dtype");
refDTypep(dtp);
dtypep(this);
widthFromSub(subDTypep());
}
ASTGEN_MEMBERS_AstMemberDType;
void dump(std::ostream& str = std::cout) const override;
void dumpJson(std::ostream& str = std::cout) const override;
void dumpSmall(std::ostream& str) const override;
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
bool hasDType() const override VL_MT_SAFE { return true; }
@@ -958,6 +973,8 @@ public:
v3fatalSrc("call isCompound on subdata type, not reference");
return false;
}
bool isConstrainedRand() const { return m_constrainedRand; }
void markConstrainedRand(bool flag) { m_constrainedRand = flag; }
};
class AstNBACommitQueueDType final : public AstNodeDType {
// @astgen ptr := m_subDTypep : AstNodeDType // Type of the corresponding variable
@@ -1054,7 +1071,7 @@ class AstQueueDType final : public AstNodeDType {
public:
AstQueueDType(FileLine* fl, VFlagChildDType, AstNodeDType* dtp, AstNodeExpr* boundp)
: ASTGEN_SUPER_QueueDType(fl) {
this->childDTypep(dtp);
childDTypep(dtp);
this->boundp(boundp);
refDTypep(nullptr);
dtypep(nullptr); // V3Width will resolve
@@ -1114,7 +1131,7 @@ public:
AstRefDType(FileLine* fl, const string& name, AstNodeExpr* classOrPackagep, AstPin* paramsp)
: ASTGEN_SUPER_RefDType(fl)
, m_name{name} {
this->classOrPackageOpp(classOrPackagep);
classOrPackageOpp(classOrPackagep);
addParamsp(paramsp);
}
class FlagTypeOfExpr {}; // type(expr) for parser only
@@ -1331,7 +1348,7 @@ class AstUnpackArrayDType final : public AstNodeArrayDType {
public:
AstUnpackArrayDType(FileLine* fl, VFlagChildDType, AstNodeDType* dtp, AstRange* rangep)
: ASTGEN_SUPER_UnpackArrayDType(fl) {
this->childDTypep(dtp); // Only for parser
childDTypep(dtp); // Only for parser
this->rangep(rangep);
refDTypep(nullptr);
dtypep(nullptr); // V3Width will resolve
@@ -1371,13 +1388,20 @@ public:
string verilogKwd() const override { return "struct"; }
};
class AstUnionDType final : public AstNodeUOrStructDType {
bool m_isSoft; // Is a "union soft"
public:
// UNSUP: bool isTagged;
// VSigning below is mispurposed to indicate if packed or not
AstUnionDType(FileLine* fl, VSigning numericUnpack)
: ASTGEN_SUPER_UnionDType(fl, numericUnpack) {}
// isSoft implies packed
AstUnionDType(FileLine* fl, bool isSoft, VSigning numericUnpack)
: ASTGEN_SUPER_UnionDType(fl, numericUnpack)
, m_isSoft(isSoft) {
packed(packed() | m_isSoft);
}
ASTGEN_MEMBERS_AstUnionDType;
string verilogKwd() const override { return "union"; }
bool isSoft() const { return m_isSoft; }
};
#endif // Guard
+43 -20
View File
@@ -243,12 +243,12 @@ protected:
AstNodeFTaskRef(VNType t, FileLine* fl, AstNode* namep, AstNodeExpr* pinsp)
: AstNodeExpr{t, fl} {
this->namep(namep);
this->addPinsp(pinsp);
addPinsp(pinsp);
}
AstNodeFTaskRef(VNType t, FileLine* fl, const string& name, AstNodeExpr* pinsp)
: AstNodeExpr{t, fl}
, m_name{name} {
this->addPinsp(pinsp);
addPinsp(pinsp);
}
public:
@@ -542,6 +542,7 @@ public:
// Know no children, and hot function, so skip iterator for speed
// cppcheck-suppress functionConst
void iterateChildren(VNVisitorConst& v) {}
static AstNodeVarRef* varRefLValueRecurse(AstNode* nodep);
};
// === Concrete node types =====================================================
@@ -647,7 +648,7 @@ public:
: ASTGEN_SUPER_CMethodHard(fl)
, m_name{name} {
this->fromp(fromp);
this->addPinsp(pinsp);
addPinsp(pinsp);
setPurity();
}
ASTGEN_MEMBERS_AstCMethodHard;
@@ -674,7 +675,7 @@ public:
AstCast(FileLine* fl, AstNodeExpr* fromp, VFlagChildDType, AstNodeDType* dtp)
: ASTGEN_SUPER_Cast(fl) {
this->fromp(fromp);
this->childDTypep(dtp);
childDTypep(dtp);
dtypeFrom(dtp);
}
AstCast(FileLine* fl, AstNodeExpr* fromp, AstNodeDType* dtp)
@@ -728,7 +729,7 @@ public:
AstCellArrayRef(FileLine* fl, const string& name, AstNodeExpr* selp)
: ASTGEN_SUPER_CellArrayRef(fl)
, m_name{name} {
this->addSelp(selp);
addSelp(selp);
}
ASTGEN_MEMBERS_AstCellArrayRef;
// ACCESSORS
@@ -769,7 +770,7 @@ public:
: ASTGEN_SUPER_ClassOrPackageRef(fl)
, m_name{name}
, m_classOrPackageNodep{classOrPackageNodep} {
this->addParamsp(paramsp);
addParamsp(paramsp);
}
ASTGEN_MEMBERS_AstClassOrPackageRef;
// METHODS
@@ -876,7 +877,7 @@ public:
AstConsPackMember* membersp = nullptr)
: ASTGEN_SUPER_ConsPackUOrStruct(fl) {
this->dtypep(dtypep);
this->addMembersp(membersp);
addMembersp(membersp);
}
ASTGEN_MEMBERS_AstConsPackUOrStruct;
const char* broken() const override {
@@ -1155,6 +1156,20 @@ public:
string emitC() override { V3ERROR_NA_RETURN(""); }
bool cleanOut() const override { return true; }
};
class AstCvtUnpackedToQueue final : public AstNodeExpr {
// Cast from unpacked array to dynamic/unpacked queue data type
// @astgen op1 := fromp : AstNodeExpr
public:
AstCvtUnpackedToQueue(FileLine* fl, AstNodeExpr* fromp, AstNodeDType* dtp)
: ASTGEN_SUPER_CvtUnpackedToQueue(fl) {
this->fromp(fromp);
dtypeFrom(dtp);
}
ASTGEN_MEMBERS_AstCvtUnpackedToQueue;
string emitVerilog() override { V3ERROR_NA_RETURN(""); }
string emitC() override { return "VL_CVT_UNPACK_TO_Q(%P, %li)"; }
bool cleanOut() const override { return true; }
};
class AstDist final : public AstNodeExpr {
// @astgen op1 := exprp : AstNodeExpr
// @astgen op2 := itemsp : List[AstDistItem]
@@ -1162,7 +1177,7 @@ public:
AstDist(FileLine* fl, AstNodeExpr* exprp, AstDistItem* itemsp)
: ASTGEN_SUPER_Inside(fl) {
this->exprp(exprp);
this->addItemsp(itemsp);
addItemsp(itemsp);
dtypeSetBit();
}
ASTGEN_MEMBERS_AstDist;
@@ -1552,7 +1567,7 @@ public:
AstInside(FileLine* fl, AstNodeExpr* exprp, AstNodeExpr* itemsp)
: ASTGEN_SUPER_Inside(fl) {
this->exprp(exprp);
this->addItemsp(itemsp);
addItemsp(itemsp);
dtypeSetBit();
}
ASTGEN_MEMBERS_AstInside;
@@ -1599,6 +1614,7 @@ public:
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
void name(const string& name) override { m_name = name; }
bool index() const { return m_index; }
bool isExprCoverageEligible() const override { return false; }
};
class AstMemberSel final : public AstNodeExpr {
// @astgen op1 := fromp : AstNodeExpr
@@ -1668,7 +1684,7 @@ class AstParseHolder final : public AstNodeExpr {
// A reference to something soon to replace, used in a select at parse time
// that needs conversion to pull the upper lvalue later
public:
AstParseHolder(FileLine* fl)
explicit AstParseHolder(FileLine* fl)
: ASTGEN_SUPER_ParseHolder(fl) {}
ASTGEN_MEMBERS_AstParseHolder;
string emitVerilog() override { V3ERROR_NA_RETURN(""); }
@@ -1744,7 +1760,7 @@ class AstPatMember final : public AstNodeExpr {
public:
AstPatMember(FileLine* fl, AstNodeExpr* lhssp, AstNode* keyp, AstNodeExpr* repp)
: ASTGEN_SUPER_PatMember(fl) {
this->addLhssp(lhssp);
addLhssp(lhssp);
this->keyp(keyp);
this->repp(repp);
}
@@ -1820,7 +1836,6 @@ public:
return "VL_RANDOM_SEEDED_%nq%lq(%li)";
}
}
if (isWide()) {
return "VL_RANDOM_%nq(%nw, %P)";
} else {
@@ -1830,6 +1845,7 @@ public:
bool cleanOut() const override { return false; }
bool isGateOptimizable() const override { return false; }
bool isPredictOptimizable() const override { return false; }
bool isPure() override { return !m_reset && !seedp(); }
int instrCount() const override { return INSTR_COUNT_PLI; }
bool sameNode(const AstNode* /*samep*/) const override { return true; }
bool combinable(const AstRand* samep) const {
@@ -1911,6 +1927,7 @@ public:
}
ASTGEN_MEMBERS_AstSFormatF;
string name() const override VL_MT_STABLE { return m_text; }
void name(const string& name) override { m_text = name; }
int instrCount() const override { return INSTR_COUNT_PLI; }
bool sameNode(const AstNode* samep) const override {
return text() == VN_DBG_AS(samep, SFormatF)->text();
@@ -1941,7 +1958,7 @@ public:
AstSScanF(FileLine* fl, const string& text, AstNode* fromp, AstNode* exprsp)
: ASTGEN_SUPER_SScanF(fl)
, m_text{text} {
this->addExprsp(exprsp);
addExprsp(exprsp);
this->fromp(fromp);
}
ASTGEN_MEMBERS_AstSScanF;
@@ -2029,7 +2046,7 @@ public:
AstSelLoopVars(FileLine* fl, AstNodeExpr* fromp, AstNode* elementsp)
: ASTGEN_SUPER_SelLoopVars(fl) {
this->fromp(fromp);
this->addElementsp(elementsp);
addElementsp(elementsp);
}
ASTGEN_MEMBERS_AstSelLoopVars;
bool sameNode(const AstNode* /*samep*/) const override { return true; }
@@ -2150,7 +2167,7 @@ class AstSysIgnore final : public AstNodeExpr {
public:
AstSysIgnore(FileLine* fl, AstNode* exprsp)
: ASTGEN_SUPER_SysIgnore(fl) {
this->addExprsp(exprsp);
addExprsp(exprsp);
}
ASTGEN_MEMBERS_AstSysIgnore;
string verilogKwd() const override { return "$ignored"; }
@@ -2261,7 +2278,7 @@ class AstUCFunc final : public AstNodeExpr {
public:
AstUCFunc(FileLine* fl, AstNode* exprsp)
: ASTGEN_SUPER_UCFunc(fl) {
this->addExprsp(exprsp);
addExprsp(exprsp);
}
ASTGEN_MEMBERS_AstUCFunc;
bool cleanOut() const override { return false; }
@@ -2343,7 +2360,7 @@ public:
: ASTGEN_SUPER_With(fl) {
this->indexArgRefp(indexArgRefp);
this->valueArgRefp(valueArgRefp);
this->addExprp(exprp);
addExprp(exprp);
}
ASTGEN_MEMBERS_AstWith;
bool sameNode(const AstNode* /*samep*/) const override { return true; }
@@ -2368,7 +2385,7 @@ public:
AstWithParse(FileLine* fl, AstNodeExpr* funcrefp, AstNode* exprsp)
: ASTGEN_SUPER_WithParse(fl) {
this->funcrefp(funcrefp);
this->addExprsp(exprsp);
addExprsp(exprsp);
}
ASTGEN_MEMBERS_AstWithParse;
bool sameNode(const AstNode* /*samep*/) const override { return true; }
@@ -4151,7 +4168,7 @@ public:
return new AstArraySel{fileline(), lhsp, rhsp};
}
void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override {
V3ERROR_NA; /* How can from be a const? */
V3ERROR_NA; // How can from be a const?
}
string emitVerilog() override { return "%k(%l%f[%r])"; }
string emitC() override { return "%li%k[%ri]"; }
@@ -4405,12 +4422,15 @@ public:
class AstNew final : public AstNodeFTaskRef {
// New as constructor
// Don't need the class we are extracting from, as the "fromp()"'s datatype can get us to it
bool m_isImplicit = false; // Implicitly generated from extends args
public:
AstNew(FileLine* fl, AstNodeExpr* pinsp)
: ASTGEN_SUPER_New(fl, "new", pinsp) {}
ASTGEN_MEMBERS_AstNew;
bool sameNode(const AstNode* /*samep*/) const override { return true; }
int instrCount() const override { return widthInstrs(); }
bool isImplicit() const { return m_isImplicit; }
void isImplicit(bool flag) { m_isImplicit = flag; }
};
class AstTaskRef final : public AstNodeFTaskRef {
// A reference to a task
@@ -4511,7 +4531,7 @@ public:
// === AstNodeTermop ===
class AstInferredDisable final : public AstNodeTermop {
public:
AstInferredDisable(FileLine* fl)
explicit AstInferredDisable(FileLine* fl)
: ASTGEN_SUPER_InferredDisable(fl) {
dtypeSetLogicSized(1, VSigning::UNSIGNED);
}
@@ -5740,6 +5760,7 @@ class AstVarXRef final : public AstNodeVarRef {
string m_name;
string m_dotted; // Dotted part of scope the name()'ed reference is under or ""
string m_inlinedDots; // Dotted hierarchy flattened out
bool m_containsGenBlock = false; // Contains gen block reference
public:
AstVarXRef(FileLine* fl, const string& name, const string& dotted, const VAccess& access)
: ASTGEN_SUPER_VarXRef(fl, nullptr, access)
@@ -5755,6 +5776,8 @@ public:
void dotted(const string& dotted) { m_dotted = dotted; }
string inlinedDots() const { return m_inlinedDots; }
void inlinedDots(const string& flag) { m_inlinedDots = flag; }
bool containsGenBlock() const { return m_containsGenBlock; }
void containsGenBlock(const bool flag) { m_containsGenBlock = flag; }
string emitVerilog() override { V3ERROR_NA_RETURN(""); }
string emitC() override { V3ERROR_NA_RETURN(""); }
bool cleanOut() const override { return true; }
+147 -58
View File
@@ -388,7 +388,7 @@ protected:
AstNodeCase(VNType t, FileLine* fl, AstNodeExpr* exprp, AstCaseItem* itemsp)
: AstNodeStmt{t, fl} {
this->exprp(exprp);
this->addItemsp(itemsp);
addItemsp(itemsp);
}
public:
@@ -414,7 +414,7 @@ public:
, m_type{type}
, m_directive{directive} {
this->propp(propp);
this->addPasssp(passsp);
addPasssp(passsp);
}
ASTGEN_MEMBERS_AstNodeCoverOrAssert;
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
@@ -440,10 +440,10 @@ protected:
AstNodeFor(VNType t, FileLine* fl, AstNode* initsp, AstNodeExpr* condp, AstNode* incsp,
AstNode* stmtsp)
: AstNodeStmt{t, fl} {
this->addInitsp(initsp);
addInitsp(initsp);
this->condp(condp);
this->addIncsp(incsp);
this->addStmtsp(stmtsp);
addIncsp(incsp);
addStmtsp(stmtsp);
}
public:
@@ -459,7 +459,7 @@ public:
AstNodeForeach(VNType t, FileLine* fl, AstNode* arrayp, AstNode* stmtsp)
: AstNodeStmt(t, fl) {
this->arrayp(arrayp);
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstNodeForeach;
bool isGateOptimizable() const override { return false; }
@@ -477,8 +477,8 @@ protected:
AstNodeIf(VNType t, FileLine* fl, AstNodeExpr* condp, AstNode* thensp, AstNode* elsesp)
: AstNodeStmt{t, fl} {
this->condp(condp);
this->addThensp(thensp);
this->addElsesp(elsesp);
addThensp(thensp);
addElsesp(elsesp);
isBoundsCheck(false);
}
@@ -598,7 +598,7 @@ public:
: ASTGEN_SUPER_Bind(fl)
, m_name{name} {
UASSERT_OBJ(VN_IS(cellsp, Cell), cellsp, "Only instances allowed to be bound");
this->addCellsp(cellsp);
addCellsp(cellsp);
}
ASTGEN_MEMBERS_AstBind;
// ACCESSORS
@@ -625,13 +625,16 @@ class AstCFunc final : public AstNode {
bool m_isTrace : 1; // Function is related to tracing
bool m_dontCombine : 1; // V3Combine shouldn't compare this func tree, it's special
bool m_declPrivate : 1; // Declare it private
bool m_keepIfEmpty : 1; // Keep declaration and definition separate, even if empty
bool m_slow : 1; // Slow routine, called once or just at init time
bool m_funcPublic : 1; // From user public task/function
bool m_isConstructor : 1; // Is C class constructor
bool m_isDestructor : 1; // Is C class destructor
bool m_isMethod : 1; // Is inside a class definition
bool m_isLoose : 1; // Semantically this is a method, but is implemented as a function
// with an explicitly passed 'self' pointer as the first argument
bool m_isLoose : 1; // Semantically this is a method, but is implemented as a function with
// an explicitly passed 'self' pointer as the first argument. This can
// be slightly faster due to __restrict, and we do not declare in header
// so adding/removing loose functions doesn't recompile everything.
bool m_isInline : 1; // Inline function
bool m_isVirtual : 1; // Virtual function
bool m_entryPoint : 1; // User may call into this top level function
@@ -643,6 +646,7 @@ class AstCFunc final : public AstNode {
bool m_dpiImportWrapper : 1; // Wrapper for invoking DPI import prototype from generated code
bool m_needProcess : 1; // Needs access to VlProcess of the caller
bool m_recursive : 1; // Recursive or part of recursion
int m_cost; // Function call cost
public:
AstCFunc(FileLine* fl, const string& name, AstScope* scopep, const string& rtnType = "")
: ASTGEN_SUPER_CFunc(fl) {
@@ -654,6 +658,7 @@ public:
m_isTrace = false;
m_dontCombine = false;
m_declPrivate = false;
m_keepIfEmpty = false;
m_slow = false;
m_funcPublic = false;
m_isConstructor = false;
@@ -671,6 +676,7 @@ public:
m_dpiImportPrototype = false;
m_dpiImportWrapper = false;
m_recursive = false;
m_cost = v3Global.opt.instrCountDpi(); // As proxy for unknown general DPI cost
}
ASTGEN_MEMBERS_AstCFunc;
string name() const override VL_MT_STABLE { return m_name; }
@@ -685,9 +691,7 @@ public:
}
//
void name(const string& name) override { m_name = name; }
int instrCount() const override {
return dpiImportPrototype() ? v3Global.opt.instrCountDpi() : 0;
}
int instrCount() const override { return m_cost; }
VBoolOrUnknown isConst() const { return m_isConst; }
void isConst(bool flag) { m_isConst.setTrueOrFalse(flag); }
void isConst(VBoolOrUnknown flag) { m_isConst = flag; }
@@ -706,6 +710,8 @@ public:
bool dontInline() const { return dontCombine() || slow() || funcPublic(); }
bool declPrivate() const { return m_declPrivate; }
void declPrivate(bool flag) { m_declPrivate = flag; }
bool keepIfEmpty() const VL_MT_SAFE { return m_keepIfEmpty; }
void keepIfEmpty(bool flag) { m_keepIfEmpty = flag; }
bool slow() const VL_MT_SAFE { return m_slow; }
void slow(bool flag) { m_slow = flag; }
bool funcPublic() const { return m_funcPublic; }
@@ -746,10 +752,10 @@ public:
bool isCoroutine() const { return m_rtnType == "VlCoroutine"; }
void recursive(bool flag) { m_recursive = flag; }
bool recursive() const { return m_recursive; }
void cost(int cost) { m_cost = cost; }
// Special methods
bool emptyBody() const {
return argsp() == nullptr && initsp() == nullptr && stmtsp() == nullptr
&& finalsp() == nullptr;
return !keepIfEmpty() && !argsp() && !initsp() && !stmtsp() && !finalsp();
}
};
class AstCLocalScope final : public AstNode {
@@ -758,7 +764,7 @@ class AstCLocalScope final : public AstNode {
public:
AstCLocalScope(FileLine* fl, AstNode* stmtsp)
: ASTGEN_SUPER_CLocalScope(fl) {
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstCLocalScope;
};
@@ -786,8 +792,8 @@ class AstCaseItem final : public AstNode {
public:
AstCaseItem(FileLine* fl, AstNodeExpr* condsp, AstNode* stmtsp)
: ASTGEN_SUPER_CaseItem(fl) {
this->addCondsp(condsp);
this->addStmtsp(stmtsp);
addCondsp(condsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstCaseItem;
int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; }
@@ -820,8 +826,8 @@ public:
, m_hasIfaceVar{false}
, m_recursive{false}
, m_trace{true} {
this->addPinsp(pinsp);
this->addParamsp(paramsp);
addPinsp(pinsp);
addParamsp(paramsp);
this->rangep(rangep);
}
ASTGEN_MEMBERS_AstCell;
@@ -911,6 +917,7 @@ class AstClassExtends final : public AstNode {
// during early parse, then moves to dtype
// @astgen op1 := childDTypep : Optional[AstNodeDType]
// @astgen op2 := classOrPkgsp : Optional[AstNode]
// @astgen op3 := argsp : List[AstNodeExpr]
const bool m_isImplements = false; // class implements
bool m_parameterized = false; // has parameters in its statement
@@ -1033,7 +1040,7 @@ public:
AstConstraint(FileLine* fl, const string& name, AstNode* itemsp)
: ASTGEN_SUPER_Constraint(fl)
, m_name(name) {
this->addItemsp(itemsp);
addItemsp(itemsp);
}
ASTGEN_MEMBERS_AstConstraint;
void dump(std::ostream& str) const override;
@@ -1063,8 +1070,8 @@ class AstConstraintBefore final : public AstNode {
public:
AstConstraintBefore(FileLine* fl, AstNodeExpr* lhssp, AstNodeExpr* rhssp)
: ASTGEN_SUPER_ConstraintBefore(fl) {
this->addLhssp(lhssp);
this->addRhssp(rhssp);
addLhssp(lhssp);
addRhssp(rhssp);
}
ASTGEN_MEMBERS_AstConstraintBefore;
bool isGateOptimizable() const override { return false; }
@@ -1183,7 +1190,7 @@ class AstImplicit final : public AstNode {
public:
AstImplicit(FileLine* fl, AstNode* exprsp)
: ASTGEN_SUPER_Implicit(fl) {
this->addExprsp(exprsp);
addExprsp(exprsp);
}
ASTGEN_MEMBERS_AstImplicit;
};
@@ -1246,8 +1253,9 @@ public:
AstModport(FileLine* fl, const string& name, AstNode* varsp)
: ASTGEN_SUPER_Modport(fl)
, m_name{name} {
this->addVarsp(varsp);
addVarsp(varsp);
}
string verilogKwd() const override { return "modport"; }
string name() const override VL_MT_STABLE { return m_name; }
bool maybePointedTo() const override VL_MT_SAFE { return true; }
ASTGEN_MEMBERS_AstModport;
@@ -1640,7 +1648,7 @@ class AstSenTree final : public AstNode {
public:
AstSenTree(FileLine* fl, AstSenItem* sensesp)
: ASTGEN_SUPER_SenTree(fl) {
this->addSensesp(sensesp);
addSensesp(sensesp);
}
ASTGEN_MEMBERS_AstSenTree;
void dump(std::ostream& str) const override;
@@ -1793,18 +1801,47 @@ public:
AstUdpTable(FileLine* fl, AstUdpTableLine* linesp)
: ASTGEN_SUPER_UdpTable(fl) {
this->addLinesp(linesp);
if (!v3Global.hasTable()) v3Global.setHasTable();
}
ASTGEN_MEMBERS_AstUdpTable;
};
class AstUdpTableLine final : public AstNode {
string m_text;
// @astgen op1 := iFieldsp : List[AstUdpTableLineVal] // Input fields
// @astgen op2 := oFieldsp : List[AstUdpTableLineVal] // Output fields
private:
const bool m_udpIsCombo; // Combinational or sequential UDP
public:
AstUdpTableLine(FileLine* fl, const string& text)
class UdpCombo {};
AstUdpTableLine(UdpCombo, FileLine* fl, AstUdpTableLineVal* iFieldsp,
AstUdpTableLineVal* oFieldsp)
: ASTGEN_SUPER_UdpTableLine(fl)
, m_text{text} {}
, m_udpIsCombo{true} {
addIFieldsp(iFieldsp);
addOFieldsp(oFieldsp);
}
class UdpSequential {};
AstUdpTableLine(UdpSequential, FileLine* fl, AstUdpTableLineVal* iFieldsp,
AstUdpTableLineVal* oFieldsp1, AstUdpTableLineVal* oFieldsp2)
: ASTGEN_SUPER_UdpTableLine(fl)
, m_udpIsCombo{false} {
addIFieldsp(iFieldsp);
addOFieldsp(oFieldsp1);
addOFieldsp(oFieldsp2);
}
ASTGEN_MEMBERS_AstUdpTableLine;
int udpIsCombo() const { return m_udpIsCombo; }
};
class AstUdpTableLineVal final : public AstNode {
string m_text; // Value character
public:
AstUdpTableLineVal(FileLine* fl, const string& text)
: ASTGEN_SUPER_UdpTableLineVal(fl)
, m_text{text} {}
ASTGEN_MEMBERS_AstUdpTableLineVal;
string name() const override VL_MT_STABLE { return m_text; }
void name(std::string const& text) override VL_MT_STABLE { m_text = text; }
string text() const VL_MT_SAFE { return m_text; }
};
class AstVar final : public AstNode {
@@ -1873,6 +1910,7 @@ class AstVar final : public AstNode {
bool m_isWrittenByDpi : 1; // This variable can be written by a DPI Export
bool m_isWrittenBySuspendable : 1; // This variable can be written by a suspendable process
bool m_ignorePostWrite : 1; // Ignore writes in 'Post' blocks during ordering
bool m_ignoreSchedWrite : 1; // Ignore writes in scheduling (for coverage increments)
void init() {
m_ansi = false;
@@ -1918,6 +1956,7 @@ class AstVar final : public AstNode {
m_isWrittenByDpi = false;
m_isWrittenBySuspendable = false;
m_ignorePostWrite = false;
m_ignoreSchedWrite = false;
m_attrClocker = VVarAttrClocker::CLOCKER_UNKNOWN;
}
@@ -2075,6 +2114,8 @@ public:
void setWrittenBySuspendable() { m_isWrittenBySuspendable = true; }
bool ignorePostWrite() const { return m_ignorePostWrite; }
void setIgnorePostWrite() { m_ignorePostWrite = true; }
bool ignoreSchedWrite() const { return m_ignoreSchedWrite; }
void setIgnoreSchedWrite() { m_ignoreSchedWrite = true; }
// METHODS
void name(const string& name) override { m_name = name; }
@@ -2160,6 +2201,8 @@ public:
string verilogKwd() const override;
void lifetime(const VLifetime& flag) { m_lifetime = flag; }
VLifetime lifetime() const { return m_lifetime; }
void pinNum(int id) { m_pinNum = id; }
int pinNum() const { return m_pinNum; }
void propagateAttrFrom(const AstVar* fromp) {
// This is getting connected to fromp; keep attributes
// Note the method below too
@@ -2192,9 +2235,11 @@ public:
m_direction = VDirection::NONE;
m_name = name;
}
bool needsCReset() const {
return !isIfaceParent() && !isIfaceRef() && !noReset() && !isParam() && !isStatementTemp()
&& !(basicp() && (basicp()->isEvent() || basicp()->isTriggerVec()));
}
static AstVar* scVarRecurse(AstNode* nodep);
void pinNum(int id) { m_pinNum = id; }
int pinNum() const { return m_pinNum; }
};
class AstVarScope final : public AstNode {
// A particular scoped usage of a variable
@@ -2297,7 +2342,7 @@ public:
class AstLet final : public AstNodeFTask {
// Verilog "let" statement
// Parents: MODULE
// stmtp is always a StmtExpr as Let always returns AstNodeExpr
// stmtp list first item is returned StmtExpr, as Let always returns AstNodeExpr
public:
AstLet(FileLine* fl, const string& name)
: ASTGEN_SUPER_Let(fl, name, nullptr) {}
@@ -2377,7 +2422,6 @@ class AstClass final : public AstNodeModule {
bool m_extended = false; // Is extension or extended by other classes
bool m_interfaceClass = false; // Interface class
bool m_needRNG = false; // Need RNG, uses srandom/randomize
bool m_parameterized = false; // Parameterized class
bool m_useVirtualPublic = false; // Subclasses need virtual public as uses interface class
bool m_virtual = false; // Virtual class
@@ -2398,8 +2442,6 @@ public:
void isExtended(bool flag) { m_extended = flag; }
bool isInterfaceClass() const { return m_interfaceClass; }
void isInterfaceClass(bool flag) { m_interfaceClass = flag; }
bool isParameterized() const { return m_parameterized; }
void isParameterized(bool flag) { m_parameterized = flag; }
bool isVirtual() const { return m_virtual; }
void isVirtual(bool flag) { m_virtual = flag; }
bool needRNG() const { return m_needRNG; }
@@ -2479,14 +2521,28 @@ public:
};
class AstModule final : public AstNodeModule {
// A module declaration
const bool m_isProgram; // Module represents a program
const bool m_isChecker = false; // Module represents a checker
const bool m_isProgram = false; // Module represents a program
public:
AstModule(FileLine* fl, const string& name, bool program = false)
class Checker {}; // for constructor type-overload selection
class Program {}; // for constructor type-overload selection
AstModule(FileLine* fl, const string& name)
: ASTGEN_SUPER_Module(fl, name) {}
AstModule(FileLine* fl, const string& name, Checker)
: ASTGEN_SUPER_Module(fl, name)
, m_isProgram{program} {}
, m_isChecker{true} {}
AstModule(FileLine* fl, const string& name, Program)
: ASTGEN_SUPER_Module(fl, name)
, m_isProgram{true} {}
ASTGEN_MEMBERS_AstModule;
string verilogKwd() const override { return m_isProgram ? "program" : "module"; }
string verilogKwd() const override {
return m_isChecker ? "checker" : m_isProgram ? "program" : "module";
}
bool timescaleMatters() const override { return true; }
bool isChecker() const { return m_isChecker; }
bool isProgram() const { return m_isProgram; }
void dump(std::ostream& str) const override;
void dumpJson(std::ostream& str) const override;
};
class AstNotFoundModule final : public AstNodeModule {
// A missing module declaration
@@ -2735,15 +2791,22 @@ public:
class AstCReset final : public AstNodeStmt {
// Reset variable at startup
// @astgen op1 := varrefp : AstVarRef
const bool m_constructing; // Previously cleared by constructor
public:
AstCReset(FileLine* fl, AstVarRef* varrefp)
: ASTGEN_SUPER_CReset(fl) {
AstCReset(FileLine* fl, AstVarRef* varrefp, bool constructing)
: ASTGEN_SUPER_CReset(fl)
, m_constructing(constructing) {
this->varrefp(varrefp);
}
ASTGEN_MEMBERS_AstCReset;
void dump(std::ostream& str) const override;
void dumpJson(std::ostream& str) const override;
bool isGateOptimizable() const override { return false; }
bool isPredictOptimizable() const override { return false; }
bool sameNode(const AstNode* /*samep*/) const override { return true; }
bool sameNode(const AstNode* samep) const override {
return constructing() == VN_DBG_AS(samep, CReset)->constructing();
}
bool constructing() const { return m_constructing; }
};
class AstCReturn final : public AstNodeStmt {
// C++ return from a function
@@ -2763,7 +2826,7 @@ class AstCStmt final : public AstNodeStmt {
public:
AstCStmt(FileLine* fl, AstNode* exprsp)
: ASTGEN_SUPER_CStmt(fl) {
this->addExprsp(exprsp);
addExprsp(exprsp);
}
inline AstCStmt(FileLine* fl, const string& textStmt);
ASTGEN_MEMBERS_AstCStmt;
@@ -2812,7 +2875,7 @@ class AstConstraintUnique final : public AstNodeStmt {
public:
AstConstraintUnique(FileLine* fl, AstNode* rangesp)
: ASTGEN_SUPER_ConstraintUnique(fl) {
this->addRangesp(rangesp);
addRangesp(rangesp);
}
ASTGEN_MEMBERS_AstConstraintUnique;
bool isGateOptimizable() const override { return false; }
@@ -2978,14 +3041,14 @@ public:
AstNodeExpr* exprsp, char missingArgChar = 'd')
: ASTGEN_SUPER_Display(fl)
, m_displayType{dispType} {
this->fmtp(new AstSFormatF{fl, text, true, exprsp, missingArgChar});
fmtp(new AstSFormatF{fl, text, true, exprsp, missingArgChar});
this->filep(filep);
}
AstDisplay(FileLine* fl, VDisplayType dispType, AstNodeExpr* filep, AstNodeExpr* exprsp,
char missingArgChar = 'd')
: ASTGEN_SUPER_Display(fl)
, m_displayType{dispType} {
this->fmtp(new AstSFormatF{fl, AstSFormatF::NoFormat{}, exprsp, missingArgChar});
fmtp(new AstSFormatF{fl, AstSFormatF::NoFormat{}, exprsp, missingArgChar});
this->filep(filep);
}
ASTGEN_MEMBERS_AstDisplay;
@@ -3058,7 +3121,7 @@ public:
AstEventControl(FileLine* fl, AstSenTree* sensesp, AstNode* stmtsp)
: ASTGEN_SUPER_EventControl(fl) {
this->sensesp(sensesp);
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstEventControl;
string verilogKwd() const override { return "@(%l) %r"; }
@@ -3139,7 +3202,7 @@ public:
// After construction must call ->labelp to associate with appropriate label
AstJumpBlock(FileLine* fl, AstNode* stmtsp)
: ASTGEN_SUPER_JumpBlock(fl) {
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstJumpBlock;
const char* broken() const override;
@@ -3271,7 +3334,7 @@ public:
AstRepeat(FileLine* fl, AstNodeExpr* countp, AstNode* stmtsp)
: ASTGEN_SUPER_Repeat(fl) {
this->countp(countp);
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstRepeat;
bool isGateOptimizable() const override { return false; } // Not relevant - converted to FOR
@@ -3300,12 +3363,12 @@ public:
AstSFormat(FileLine* fl, AstNodeExpr* lhsp, const string& text, AstNodeExpr* exprsp,
char missingArgChar = 'd')
: ASTGEN_SUPER_SFormat(fl) {
this->fmtp(new AstSFormatF{fl, text, true, exprsp, missingArgChar});
fmtp(new AstSFormatF{fl, text, true, exprsp, missingArgChar});
this->lhsp(lhsp);
}
AstSFormat(FileLine* fl, AstNodeExpr* lhsp, AstNodeExpr* exprsp, char missingArgChar = 'd')
: ASTGEN_SUPER_SFormat(fl) {
this->fmtp(new AstSFormatF{fl, AstSFormatF::NoFormat{}, exprsp, missingArgChar});
fmtp(new AstSFormatF{fl, AstSFormatF::NoFormat{}, exprsp, missingArgChar});
this->lhsp(lhsp);
}
ASTGEN_MEMBERS_AstSFormat;
@@ -3322,6 +3385,24 @@ public:
int instrCount() const override { return INSTR_COUNT_PLI; }
bool sameNode(const AstNode* /*samep*/) const override { return true; }
};
class AstSetuphold final : public AstNodeStmt {
// Verilog $setuphold
// @astgen op1 := refevp : AstNodeExpr
// @astgen op2 := dataevp : AstNodeExpr
// @astgen op3 := delrefp : Optional[AstNodeExpr]
// @astgen op4 := deldatap : Optional[AstNodeExpr]
public:
AstSetuphold(FileLine* fl, AstNodeExpr* refevp, AstNodeExpr* dataevp,
AstNodeExpr* delrefp = nullptr, AstNodeExpr* deldatap = nullptr)
: ASTGEN_SUPER_Setuphold(fl) {
this->refevp(refevp);
this->dataevp(dataevp);
this->delrefp(delrefp);
this->deldatap(deldatap);
}
ASTGEN_MEMBERS_AstSetuphold;
bool sameNode(const AstNode* /*samep*/) const override { return true; }
};
class AstStackTraceT final : public AstNodeStmt {
// $stacktrace used as task
public:
@@ -3535,7 +3616,7 @@ class AstUCStmt final : public AstNodeStmt {
public:
AstUCStmt(FileLine* fl, AstNode* exprsp)
: ASTGEN_SUPER_UCStmt(fl) {
this->addExprsp(exprsp);
addExprsp(exprsp);
}
ASTGEN_MEMBERS_AstUCStmt;
bool isGateOptimizable() const override { return false; }
@@ -3551,7 +3632,7 @@ public:
AstWait(FileLine* fl, AstNodeExpr* condp, AstNode* stmtsp)
: ASTGEN_SUPER_Wait(fl) {
this->condp(condp);
this->addStmtsp(stmtsp);
addStmtsp(stmtsp);
}
ASTGEN_MEMBERS_AstWait;
bool isFirstInMyListOfStatements(AstNode* n) const override { return n == stmtsp(); }
@@ -3575,8 +3656,8 @@ public:
AstWhile(FileLine* fl, AstNodeExpr* condp, AstNode* stmtsp = nullptr, AstNode* incsp = nullptr)
: ASTGEN_SUPER_While(fl) {
this->condp(condp);
this->addStmtsp(stmtsp);
this->addIncsp(incsp);
addStmtsp(stmtsp);
addIncsp(incsp);
}
ASTGEN_MEMBERS_AstWhile;
void dump(std::ostream& str) const override;
@@ -3751,7 +3832,7 @@ public:
AstAssert(FileLine* fl, AstNode* propp, AstNode* passsp, AstNode* failsp, VAssertType type,
VAssertDirectiveType directive, const string& name = "")
: ASTGEN_SUPER_Assert(fl, propp, passsp, type, directive, name) {
this->addFailsp(failsp);
addFailsp(failsp);
}
};
class AstAssertIntrinsic final : public AstNodeCoverOrAssert {
@@ -3764,7 +3845,7 @@ public:
// Intrinsic asserts are always enabled thus 'type' field is set to INTERNAL.
: ASTGEN_SUPER_AssertIntrinsic(fl, propp, passsp, VAssertType::INTERNAL,
VAssertDirectiveType::INTRINSIC, name) {
this->addFailsp(failsp);
addFailsp(failsp);
}
};
class AstCover final : public AstNodeCoverOrAssert {
@@ -3881,6 +3962,14 @@ public:
bool isPure() override { return false; } // SPECIAL: User may order w/other sigs
bool isOutputter() override { return true; }
};
class AstScHdrPost final : public AstNodeText {
public:
AstScHdrPost(FileLine* fl, const string& textp)
: ASTGEN_SUPER_ScHdrPost(fl, textp) {}
ASTGEN_MEMBERS_AstScHdrPost;
bool isPure() override { return false; } // SPECIAL: User may order w/other sigs
bool isOutputter() override { return true; }
};
class AstScImp final : public AstNodeText {
public:
AstScImp(FileLine* fl, const string& textp)
+123 -28
View File
@@ -327,6 +327,15 @@ AstNodeExpr* AstInsideRange::newAndFromInside(AstNodeExpr* exprp, AstNodeExpr* l
return new AstLogAnd{fileline(), ap, bp};
}
void AstCReset::dump(std::ostream& str) const {
this->AstNode::dump(str);
if (constructing()) str << " [CONS]";
}
void AstCReset::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, constructing);
dumpJsonGen(str);
}
AstVar* AstClocking::ensureEventp(bool childDType) {
if (!eventp()) {
AstVar* const evp
@@ -570,15 +579,28 @@ string AstVar::vlEnumDir() const {
string AstVar::vlPropDecl(const string& propName) const {
string out;
std::vector<int> plims; // Packed dimension limits
std::vector<int> ulims; // Unpacked dimension limits
for (const AstNodeDType* dtp = dtypep(); dtp;) {
dtp = dtp->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (const AstNodeArrayDType* const adtypep = VN_CAST(dtp, NodeArrayDType)) {
ulims.push_back(adtypep->declRange().left());
ulims.push_back(adtypep->declRange().right());
dtp = adtypep->subDTypep();
} else {
break; // AstBasicDType - nothing below
if (const AstBasicDType* const bdtypep = basicp()) {
for (const AstNodeDType* dtp = dtypep(); dtp;) {
dtp = dtp->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (const AstNodeArrayDType* const adtypep = VN_CAST(dtp, NodeArrayDType)) {
if (VN_IS(dtp, PackArrayDType)) {
plims.push_back(adtypep->declRange().left());
plims.push_back(adtypep->declRange().right());
} else {
ulims.push_back(adtypep->declRange().left());
ulims.push_back(adtypep->declRange().right());
}
dtp = adtypep->subDTypep();
} else {
if (bdtypep->isRanged()) {
plims.push_back(bdtypep->left());
plims.push_back(bdtypep->right());
}
break; // AstBasicDType - nothing below
}
}
}
@@ -595,23 +617,37 @@ string AstVar::vlPropDecl(const string& propName) const {
out += "};\n";
}
if (!plims.empty()) {
out += "static const int " + propName + "__plims[";
out += cvtToStr(plims.size());
out += "] = {";
auto it = plims.cbegin();
out += cvtToStr(*it);
while (++it != plims.cend()) {
out += ", ";
out += cvtToStr(*it);
}
out += "};\n";
}
out += "static const VerilatedVarProps ";
out += propName;
out += "(";
out += vlEnumType(); // VLVT_UINT32 etc
out += ", " + vlEnumDir(); // VLVD_IN etc
if (const AstBasicDType* const bdtypep = basicp()) {
out += ", VerilatedVarProps::Packed()";
out += ", " + cvtToStr(bdtypep->left());
out += ", " + cvtToStr(bdtypep->right());
}
if (!ulims.empty()) {
out += ", VerilatedVarProps::Unpacked()";
out += ", VerilatedVarProps::Unpacked{}";
out += ", " + cvtToStr(ulims.size() / 2);
out += ", " + propName + "__ulims";
}
if (!plims.empty()) {
out += ", VerilatedVarProps::Packed{}";
out += ", " + cvtToStr(plims.size() / 2);
out += ", " + propName + "__plims";
}
out += ");\n";
return out;
}
@@ -788,12 +824,12 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) {
}
} else if (AstArraySel* const arraySelp = VN_CAST(nodep, ArraySel)) {
if (AstVar* const p = scVarRecurse(arraySelp->fromp())) return p;
if (AstVar* const p = scVarRecurse(arraySelp->bitp())) return p;
}
return nullptr;
}
const AstNodeDType* AstNodeDType::skipRefIterp(bool skipConst, bool skipEnum) const VL_MT_STABLE {
const AstNodeDType* AstNodeDType::skipRefIterp(bool skipConst, bool skipEnum,
bool assertOn) const VL_MT_STABLE {
const AstNodeDType* nodep = this;
while (true) {
if (VL_UNLIKELY(VN_IS(nodep, MemberDType) || VN_IS(nodep, ParamTypeDType)
@@ -804,7 +840,7 @@ const AstNodeDType* AstNodeDType::skipRefIterp(bool skipConst, bool skipEnum) co
nodep = subp;
continue;
} else {
nodep->v3fatalSrc(nodep->prettyTypeName() << " not linked to type");
if (assertOn) nodep->v3fatalSrc(nodep->prettyTypeName() << " not linked to type");
return nullptr;
}
}
@@ -812,6 +848,15 @@ const AstNodeDType* AstNodeDType::skipRefIterp(bool skipConst, bool skipEnum) co
}
}
bool AstNodeDType::similarDType(const AstNodeDType* samep) const {
const AstNodeDType* nodep = this;
nodep = nodep->skipRefToNonRefp();
samep = samep->skipRefToNonRefp();
if (nodep == samep) return true;
if (nodep->type() != samep->type()) return false;
return nodep->similarDTypeNode(samep);
}
bool AstNodeDType::isFourstate() const { return basicp() && basicp()->isFourstate(); }
class AstNodeDType::CTypeRecursed final {
@@ -971,11 +1016,11 @@ AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound, bool packe
return info;
}
uint32_t AstNodeDType::arrayUnpackedElements() {
uint32_t AstNodeDType::arrayUnpackedElements() const {
uint32_t entries = 1;
for (AstNodeDType* dtypep = this; dtypep;) {
for (const AstNodeDType* dtypep = this; dtypep;) {
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
if (const AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
entries *= adtypep->elementsConst();
dtypep = adtypep->subDTypep();
} else {
@@ -1760,7 +1805,7 @@ void AstClocking::dumpJson(std::ostream& str) const {
}
void AstDisplay::dump(std::ostream& str) const {
this->AstNodeStmt::dump(str);
// str << " " << displayType().ascii();
str << " [" << displayType().ascii() << "]";
}
void AstDisplay::dumpJson(std::ostream& str) const { dumpJsonGen(str); }
void AstEnumDType::dump(std::ostream& str) const {
@@ -1923,6 +1968,20 @@ void AstJumpLabel::dump(std::ostream& str) const {
}
void AstJumpLabel::dumpJson(std::ostream& str) const { dumpJsonGen(str); }
void AstMemberDType::dump(std::ostream& str) const {
this->AstNodeDType::dump(str);
if (isConstrainedRand()) str << " [CONSTRAINEDRAND]";
if (name() != "") str << " name=" << name();
if (tag() != "") str << " tag=" << tag();
}
void AstMemberDType::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, isConstrainedRand);
dumpJsonStrFunc(str, name);
dumpJsonStrFunc(str, tag);
dumpJsonGen(str);
}
void AstMemberDType::dumpSmall(std::ostream& str) const {
this->AstNodeDType::dumpSmall(str);
str << "member";
@@ -1945,8 +2004,8 @@ AstMemberSel::AstMemberSel(FileLine* fl, AstNodeExpr* fromp, AstVar* varp)
}
bool AstMemberSel::sameNode(const AstNode* samep) const {
const AstMemberSel* const sp = VN_DBG_AS(samep, MemberSel);
return sp != nullptr && access() == sp->access() && fromp()->isSame(sp->fromp())
&& name() == sp->name() && varp()->sameNode(sp->varp());
return sp && access() == sp->access() && fromp()->isSame(sp->fromp()) && name() == sp->name()
&& (varp() && sp->varp() && varp()->sameNode(sp->varp()));
}
void AstMemberSel::dump(std::ostream& str) const {
@@ -1989,6 +2048,16 @@ void AstModportVarRef::dumpJson(std::ostream& str) const {
dumpJsonStr(str, "direction", direction().ascii());
dumpJsonGen(str);
}
void AstModule::dump(std::ostream& str) const {
this->AstNodeModule::dump(str);
if (isChecker()) str << " [CHECKER]";
if (isProgram()) str << " [PROGRAM]";
}
void AstModule::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, isChecker);
dumpJsonBoolFunc(str, isProgram);
dumpJsonGen(str);
}
void AstPin::dump(std::ostream& str) const {
this->AstNode::dump(str);
if (modVarp()) {
@@ -2433,8 +2502,24 @@ void AstNodeVarRef::dumpJson(std::ostream& str) const {
dumpJsonStr(str, "access", access().ascii());
dumpJsonGen(str);
}
AstNodeVarRef* AstNodeVarRef::varRefLValueRecurse(AstNode* nodep) {
// Given a (possible) lvalue expression, recurse to find the being-set NodeVarRef, else nullptr
if (AstNodeVarRef* const anodep = VN_CAST(nodep, NodeVarRef)) return anodep;
if (AstNodeSel* const anodep = VN_CAST(nodep, NodeSel))
return varRefLValueRecurse(anodep->fromp());
if (AstSel* const anodep = VN_CAST(nodep, Sel)) return varRefLValueRecurse(anodep->fromp());
if (AstArraySel* const anodep = VN_CAST(nodep, ArraySel))
return varRefLValueRecurse(anodep->fromp());
if (AstMemberSel* const anodep = VN_CAST(nodep, MemberSel))
return varRefLValueRecurse(anodep->fromp());
if (AstStructSel* const anodep = VN_CAST(nodep, StructSel))
return varRefLValueRecurse(anodep->fromp());
return nullptr;
}
void AstVarXRef::dump(std::ostream& str) const {
this->AstNodeVarRef::dump(str);
if (containsGenBlock()) str << " [GENBLK]";
str << ".=" << dotted() << " ";
if (inlinedDots() != "") str << " inline.=" << inlinedDots() << " - ";
if (varScopep()) {
@@ -2446,6 +2531,7 @@ void AstVarXRef::dump(std::ostream& str) const {
}
}
void AstVarXRef::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, containsGenBlock);
dumpJsonStrFunc(str, dotted);
dumpJsonStrFunc(str, inlinedDots);
dumpJsonGen(str);
@@ -2497,6 +2583,8 @@ void AstVar::dump(std::ostream& str) const {
str << " [FUNC]";
}
if (isDpiOpenArray()) str << " [DPIOPENA]";
if (ignorePostWrite()) str << " [IGNPWR]";
if (ignoreSchedWrite()) str << " [IGNWR]";
if (!attrClocker().unknown()) str << " [" << attrClocker().ascii() << "] ";
if (!lifetime().isNone()) str << " [" << lifetime().ascii() << "] ";
str << " " << varType();
@@ -2529,6 +2617,8 @@ void AstVar::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, isParam);
dumpJsonBoolFunc(str, attrScBv);
dumpJsonBoolFunc(str, attrSFormat);
dumpJsonBoolFunc(str, ignorePostWrite);
dumpJsonBoolFunc(str, ignoreSchedWrite);
dumpJsonGen(str);
}
bool AstVar::sameNode(const AstNode* samep) const {
@@ -2615,7 +2705,9 @@ AstNodeModule* AstClassOrPackageRef::classOrPackageSkipp() const {
AstNode* lastp = nullptr;
while (foundp != lastp) {
lastp = foundp;
if (AstNodeDType* const anodep = VN_CAST(foundp, NodeDType)) foundp = anodep->skipRefp();
if (AstNodeDType* const anodep = VN_CAST(foundp, NodeDType)) {
foundp = anodep->skipRefOrNullp();
}
if (AstTypedef* const anodep = VN_CAST(foundp, Typedef)) foundp = anodep->subDTypep();
if (AstClassRefDType* const anodep = VN_CAST(foundp, ClassRefDType))
foundp = anodep->classp();
@@ -2838,15 +2930,17 @@ void AstCFile::dumpJson(std::ostream& str) const {
void AstCFunc::dump(std::ostream& str) const {
this->AstNode::dump(str);
if (slow()) str << " [SLOW]";
if (dpiPure()) str << " [DPIPURE]";
if (isStatic()) str << " [STATIC]";
if (dpiContext()) str << " [DPICTX]";
if (dpiExportDispatcher()) str << " [DPIED]";
if (dpiExportImpl()) str << " [DPIEI]";
if (dpiImportPrototype()) str << " [DPIIP]";
if (dpiImportWrapper()) str << " [DPIIW]";
if (dpiContext()) str << " [DPICTX]";
if (dpiPure()) str << " [DPIPURE]";
if (isConstructor()) str << " [CTOR]";
if (isDestructor()) str << " [DTOR]";
if (isMethod()) str << " [METHOD]";
if (isLoose()) str << " [LOOSE]";
if (isVirtual()) str << " [VIRT]";
if (isCoroutine()) str << " [CORO]";
if (needProcess()) str << " [NPRC]";
@@ -2945,7 +3039,8 @@ void AstCMethodHard::setPurity() {
{"resume", false},
{"reverse", false},
{"rsort", false},
{"set", false},
{"setBit", false},
{"setWord", false},
{"set_randmode", false},
{"shuffle", false},
{"size", true},
@@ -3012,7 +3107,7 @@ AstAlways* AstAssignW::convertToAlways() {
if (hasTimingControl) {
// If there's a timing control, put the assignment in a fork..join_none. This process won't
// get marked as suspendable and thus will be scheduled normally
auto* forkp = new AstFork{flp, "", bodysp};
AstFork* forkp = new AstFork{flp, "", bodysp};
forkp->joinType(VJoinType::JOIN_NONE);
bodysp = forkp;
}
+1 -1
View File
@@ -99,7 +99,7 @@ public:
}
// Get a pointer to the user data if exists, otherwise nullptr
T_Data* tryGet(const T_Node* nodep) { return getUserp(nodep); }
T_Data* tryGet(const T_Node* nodep) const { return getUserp(nodep); }
void clear() { m_allocated.clear(); }
};
+16 -3
View File
@@ -148,6 +148,18 @@ class BeginVisitor final : public VNVisitor {
void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp);
m_modp = nodep;
// Rename it (e.g. class under a generate)
if (m_unnamedScope != "") {
nodep->name(dot(m_unnamedScope, nodep->name()));
UINFO(8, " rename to " << nodep->name() << endl);
m_statep->userMarkChanged(nodep);
}
VL_RESTORER(m_displayScope);
VL_RESTORER(m_namedScope);
VL_RESTORER(m_unnamedScope);
m_displayScope = "";
m_namedScope = "";
m_unnamedScope = "";
iterateChildren(nodep);
}
void visit(AstNodeFTask* nodep) override {
@@ -365,7 +377,7 @@ void V3Begin::debeginAll(AstNetlist* nodep) {
{
BeginState state;
{ BeginVisitor{nodep, &state}; }
if (state.anyFuncInBegin()) { BeginRelinkVisitor{nodep, &state}; }
if (state.anyFuncInBegin()) BeginRelinkVisitor{nodep, &state};
} // Destruct before checking
V3Global::dumpCheckGlobalTree("begin", 0, dumpTreeEitherLevel() >= 3);
}
@@ -494,8 +506,9 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
AstNode* const first_clearp
= new AstAssign{fl, new AstVarRef{fl, first_varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitFalse{}}};
auto* const orp = new AstLogOr{fl, new AstVarRef{fl, first_varp, VAccess::READ},
new AstNeq{fl, new AstConst{fl, 0}, nextp}};
AstLogOr* const orp
= new AstLogOr{fl, new AstVarRef{fl, first_varp, VAccess::READ},
new AstNeq{fl, new AstConst{fl, 0}, nextp}};
AstNode* const whilep = new AstWhile{fl, orp, first_clearp};
first_clearp->addNext(bodyPointp);
AstNode* const ifbodyp
+22 -11
View File
@@ -62,6 +62,7 @@ class V3CCtorsBuilder final {
AstCFunc* const funcp = new AstCFunc{m_modp->fileline(), funcName, nullptr, "void"};
funcp->isStatic(false);
funcp->isLoose(!m_type.isClass());
funcp->keepIfEmpty(true); // TODO relax
funcp->declPrivate(true);
funcp->slow(!m_type.isClass()); // Only classes construct on fast path
string preventUnusedStmt;
@@ -113,7 +114,7 @@ public:
callp->argTypes("vlSymsp");
} else {
if (m_type.isCoverage()) callp->argTypes("first");
callp->selfPointer(VSelfPointerText{VSelfPointerText::This()});
callp->selfPointer(VSelfPointerText{VSelfPointerText::This{}});
}
rootFuncp->addStmtsp(callp->makeStmt());
}
@@ -136,7 +137,17 @@ class CCtorsVisitor final : public VNVisitor {
AstCFunc* m_cfuncp = nullptr; // Current function
V3CCtorsBuilder* m_varResetp = nullptr; // Builder of _ctor_var_reset
// VISITs
// METHODS
static void insertSc(AstCFunc* cfuncp, const AstNodeModule* modp, VNType type) {
auto textAndFileline = EmitCBaseVisitorConst::textSection(modp, type);
if (!textAndFileline.first.empty()) {
AstTextBlock* const newp
= new AstTextBlock{textAndFileline.second, textAndFileline.first, false, false};
cfuncp->addStmtsp(newp);
}
}
// VISITORS
void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp);
VL_RESTORER(m_varResetp);
@@ -166,6 +177,7 @@ class CCtorsVisitor final : public VNVisitor {
// If can be referred to by base pointer, need virtual delete
funcp->isVirtual(classp->isExtended());
funcp->slow(false);
insertSc(funcp, classp, VNType::atScDtor);
classp->addStmtsp(funcp);
}
}
@@ -176,18 +188,16 @@ class CCtorsVisitor final : public VNVisitor {
m_varResetp = nullptr;
m_cfuncp = nodep;
iterateChildren(nodep);
if (nodep->name() == "new") insertSc(nodep, m_modp, VNType::atScCtor);
}
void visit(AstVar* nodep) override {
if (!nodep->isIfaceParent() && !nodep->isIfaceRef() && !nodep->noReset()
&& !nodep->isParam() && !nodep->isStatementTemp()
&& !(nodep->basicp()
&& (nodep->basicp()->isEvent() || nodep->basicp()->isTriggerVec()))) {
if (nodep->needsCReset()) {
if (m_varResetp) {
const auto vrefp = new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE};
m_varResetp->add(new AstCReset{nodep->fileline(), vrefp});
AstVarRef* const vrefp = new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE};
m_varResetp->add(new AstCReset{nodep->fileline(), vrefp, true});
} else if (m_cfuncp) {
const auto vrefp = new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE};
nodep->addNextHere(new AstCReset{nodep->fileline(), vrefp});
AstVarRef* const vrefp = new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE};
nodep->addNextHere(new AstCReset{nodep->fileline(), vrefp, true});
}
}
}
@@ -210,6 +220,7 @@ void V3CCtors::evalAsserts() {
funcp->declPrivate(true);
funcp->isStatic(false);
funcp->isLoose(true);
funcp->keepIfEmpty(true);
funcp->slow(false);
funcp->ifdef("VL_DEBUG");
modp->addStmtsp(funcp);
@@ -224,7 +235,7 @@ void V3CCtors::evalAsserts() {
// if (signal & CONST(upper_non_clean_mask)) { fail; }
AstVarRef* const vrefp
= new AstVarRef{varp->fileline(), varp, VAccess::READ};
vrefp->selfPointer(VSelfPointerText{VSelfPointerText::This()});
vrefp->selfPointer(VSelfPointerText{VSelfPointerText::This{}});
AstNodeExpr* newp = vrefp;
if (varp->isWide()) {
newp = new AstWordSel{
+2 -2
View File
@@ -72,13 +72,13 @@ class CaseLintVisitor final : public VNVisitorConst {
// Check for X/Z in non-casex statements
{
VL_RESTORER(m_caseExprp);
m_caseExprp = nodep;
iterateConst(nodep->exprp());
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
itemp = VN_AS(itemp->nextp(), CaseItem)) {
iterateAndNextConstNull(itemp->condsp());
}
m_caseExprp = nullptr;
}
}
void visit(AstConst* nodep) override {
@@ -578,7 +578,7 @@ class CaseVisitor final : public VNVisitor {
}
//--------------------
void visit(AstAlways* nodep) override {
VL_RESTORER(m_alwaysp)
VL_RESTORER(m_alwaysp);
m_alwaysp = nodep;
iterateChildren(nodep);
}
+1 -1
View File
@@ -188,9 +188,9 @@ class CombineVisitor final : VNVisitor {
}
void visit(AstNodeModule* nodep) override {
UASSERT_OBJ(!m_modp, nodep, "Should not nest");
VL_RESTORER(m_modp);
m_modp = nodep;
iterateChildrenConst(nodep);
m_modp = nullptr;
}
void visit(AstCFunc* nodep) override {
iterateChildrenConst(nodep);
+47 -1
View File
@@ -533,11 +533,15 @@ public:
// Resolve modules and files in the design
class V3ConfigResolver final {
enum ProfileDataMode : uint8_t { NONE = 0, MTASK = 1, HIER_DPI = 2 };
V3ConfigModuleResolver m_modules; // Access to module names (with wildcards)
V3ConfigFileResolver m_files; // Access to file names (with wildcards)
V3ConfigScopeTraceResolver m_scopeTraces; // Regexp to trace enables
std::unordered_map<string, std::unordered_map<string, uint64_t>>
m_profileData; // Access to profile_data records
uint8_t m_mode = NONE;
std::unordered_map<string, int> m_hierWorkers;
FileLine* m_hierWorkersFileLine = nullptr;
FileLine* m_profileFileLine = nullptr;
V3ConfigResolver() = default;
@@ -552,11 +556,32 @@ public:
V3ConfigFileResolver& files() { return m_files; }
V3ConfigScopeTraceResolver& scopeTraces() { return m_scopeTraces; }
void addProfileData(FileLine* fl, const string& model, const string& key, uint64_t cost) {
void addProfileData(FileLine* fl, const string& hierDpi, uint64_t cost) {
// Empty key for hierarchical DPI wrapper costs.
addProfileData(fl, hierDpi, "", cost, HIER_DPI);
}
void addProfileData(FileLine* fl, const string& model, const string& key, uint64_t cost,
ProfileDataMode mode = MTASK) {
if (!m_profileFileLine) m_profileFileLine = fl;
if (cost == 0) cost = 1; // Cost 0 means delete (or no data)
m_profileData[model][key] += cost;
m_mode |= mode;
}
bool containsMTaskProfileData() const { return m_mode & MTASK; }
uint64_t getProfileData(const string& hierDpi) const {
// Empty key for hierarchical DPI wrapper costs.
return getProfileData(hierDpi, "");
}
void addHierWorkers(FileLine* fl, const string& model, int workers) {
if (!m_hierWorkersFileLine) m_hierWorkersFileLine = fl;
m_hierWorkers[model] = workers;
}
int getHierWorkers(const string& model) const {
const auto mit = m_hierWorkers.find(model);
// Assign a single worker if no specified.
return mit != m_hierWorkers.cend() ? mit->second : 0;
}
FileLine* getHierWorkersFileLine() const { return m_hierWorkersFileLine; }
uint64_t getProfileData(const string& model, const string& key) const {
const auto mit = m_profileData.find(model);
if (mit == m_profileData.cend()) return 0;
@@ -589,6 +614,10 @@ void V3Config::addCoverageBlockOff(const string& module, const string& blockname
V3ConfigResolver::s().modules().at(module).addCoverageBlockOff(blockname);
}
void V3Config::addHierWorkers(FileLine* fl, const string& model, int workers) {
V3ConfigResolver::s().addHierWorkers(fl, model, workers);
}
void V3Config::addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max) {
if (filename == "*") {
FileLine::globalWarnOff(code, !on);
@@ -619,6 +648,10 @@ void V3Config::addModulePragma(const string& module, VPragmaType pragma) {
V3ConfigResolver::s().modules().at(module).addModulePragma(pragma);
}
void V3Config::addProfileData(FileLine* fl, const string& hierDpi, uint64_t cost) {
V3ConfigResolver::s().addProfileData(fl, hierDpi, cost);
}
void V3Config::addProfileData(FileLine* fl, const string& model, const string& key,
uint64_t cost) {
V3ConfigResolver::s().addProfileData(fl, model, key, cost);
@@ -724,6 +757,15 @@ void V3Config::applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar
if (vp) vp->apply(varp);
}
int V3Config::getHierWorkers(const string& model) {
return V3ConfigResolver::s().getHierWorkers(model);
}
FileLine* V3Config::getHierWorkersFileLine() {
return V3ConfigResolver::s().getHierWorkersFileLine();
}
uint64_t V3Config::getProfileData(const string& hierDpi) {
return V3ConfigResolver::s().getProfileData(hierDpi);
}
uint64_t V3Config::getProfileData(const string& model, const string& key) {
return V3ConfigResolver::s().getProfileData(model, key);
}
@@ -736,6 +778,10 @@ bool V3Config::getScopeTraceOn(const string& scope) {
void V3Config::contentsPushText(const string& text) { return WildcardContents::pushText(text); }
bool V3Config::containsMTaskProfileData() {
return V3ConfigResolver::s().containsMTaskProfileData();
}
bool V3Config::waive(FileLine* filelinep, V3ErrorCode code, const string& message) {
V3ConfigFile* filep = V3ConfigResolver::s().files().resolve(filelinep->filename());
if (!filep) return false;
+7
View File
@@ -33,11 +33,13 @@ public:
static void addCaseParallel(const string& file, int lineno);
static void addCoverageBlockOff(const string& file, int lineno);
static void addCoverageBlockOff(const string& module, const string& blockname);
static void addHierWorkers(FileLine* fl, const string& model, int workers);
static void addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max);
static void addIgnoreMatch(V3ErrorCode code, const string& filename, const string& contents,
const string& match);
static void addInline(FileLine* fl, const string& module, const string& ftask, bool on);
static void addModulePragma(const string& module, VPragmaType pragma);
static void addProfileData(FileLine* fl, const string& hierDpi, uint64_t cost);
static void addProfileData(FileLine* fl, const string& model, const string& key,
uint64_t cost);
static void addScopeTraceOn(bool on, const string& scope, int levels);
@@ -51,12 +53,17 @@ public:
static void applyModule(AstNodeModule* modulep);
static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp);
static int getHierWorkers(const string& model);
static FileLine* getHierWorkersFileLine();
static uint64_t getProfileData(const string& hierDpi);
static uint64_t getProfileData(const string& model, const string& key);
static FileLine* getProfileDataFileLine();
static bool getScopeTraceOn(const string& scope);
static void contentsPushText(const string& text);
static bool containsMTaskProfileData();
static bool waive(FileLine* filelinep, V3ErrorCode code, const string& message);
};
+50 -33
View File
@@ -2169,7 +2169,7 @@ class ConstVisitor final : public VNVisitor {
// Add a cast if needed.
AstStreamR* const streamp = VN_AS(nodep->rhsp(), StreamR)->unlinkFrBack();
AstNodeExpr* srcp = streamp->lhsp()->unlinkFrBack();
AstNodeDType* const srcDTypep = srcp->dtypep();
AstNodeDType* const srcDTypep = srcp->dtypep()->skipRefp();
if (VN_IS(srcDTypep, QueueDType) || VN_IS(srcDTypep, DynArrayDType)) {
srcp = new AstCvtArrayToPacked{srcp->fileline(), srcp, nodep->dtypep()};
} else if (VN_IS(srcDTypep, UnpackArrayDType)) {
@@ -2191,30 +2191,32 @@ class ConstVisitor final : public VNVisitor {
// Push the stream operator to the rhs of the assignment statement
AstNodeExpr* streamp = nodep->lhsp()->unlinkFrBack();
AstNodeExpr* const dstp = VN_AS(streamp, StreamL)->lhsp()->unlinkFrBack();
AstNodeDType* const dstDTypep = dstp->dtypep()->skipRefp();
AstNodeExpr* const srcp = nodep->rhsp()->unlinkFrBack();
AstNodeDType* const srcDTypep = srcp->dtypep()->skipRefp();
const int sWidth = srcp->width();
const int dWidth = dstp->width();
// Connect the rhs to the stream operator and update its width
VN_AS(streamp, StreamL)->lhsp(srcp);
if (VN_IS(srcp->dtypep(), DynArrayDType) || VN_IS(srcp->dtypep(), QueueDType)
|| VN_IS(srcp->dtypep(), UnpackArrayDType)) {
if (VN_IS(srcDTypep, DynArrayDType) || VN_IS(srcDTypep, QueueDType)
|| VN_IS(srcDTypep, UnpackArrayDType)) {
streamp->dtypeSetStream();
} else {
streamp->dtypeSetLogicUnsized(srcp->width(), srcp->widthMin(), VSigning::UNSIGNED);
}
if (VN_IS(dstp->dtypep(), UnpackArrayDType)) {
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstp->dtypep()};
if (VN_IS(dstDTypep, UnpackArrayDType)) {
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstDTypep};
} else {
UASSERT(sWidth >= dWidth, "sWidth >= dWidth should have caused an error earlier");
if (dWidth == 0) {
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstp->dtypep()};
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstDTypep};
} else if (sWidth >= dWidth) {
streamp = new AstSel{streamp->fileline(), streamp, sWidth - dWidth, dWidth};
}
}
nodep->lhsp(dstp);
nodep->rhsp(streamp);
nodep->dtypep(dstp->dtypep());
nodep->dtypep(dstDTypep);
return true;
} else if (m_doV && VN_IS(nodep->lhsp(), StreamR)) {
// The right stream operator on lhs of assignment statement does
@@ -2222,12 +2224,13 @@ class ConstVisitor final : public VNVisitor {
// then we select bits from the left-most, not the right-most.
AstNodeExpr* const streamp = nodep->lhsp()->unlinkFrBack();
AstNodeExpr* const dstp = VN_AS(streamp, StreamR)->lhsp()->unlinkFrBack();
AstNodeDType* const dstDTypep = dstp->dtypep()->skipRefp();
AstNodeExpr* srcp = nodep->rhsp()->unlinkFrBack();
const int sWidth = srcp->width();
const int dWidth = dstp->width();
if (VN_IS(dstp->dtypep(), UnpackArrayDType)) {
if (VN_IS(dstDTypep, UnpackArrayDType)) {
const int dstBitWidth
= dWidth * VN_AS(dstp->dtypep(), UnpackArrayDType)->arrayUnpackedElements();
= dWidth * VN_AS(dstDTypep, UnpackArrayDType)->arrayUnpackedElements();
// Handling the case where rhs is wider than lhs. StreamL does not require this
// since the combination of the left streaming operation and the implicit
// truncation in VL_ASSIGN_UNPACK automatically selects the left-most bits.
@@ -2235,30 +2238,30 @@ class ConstVisitor final : public VNVisitor {
srcp
= new AstSel{streamp->fileline(), srcp, sWidth - dstBitWidth, dstBitWidth};
}
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstp->dtypep()};
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstDTypep};
} else {
UASSERT(sWidth >= dWidth, "sWidth >= dWidth should have caused an error earlier");
if (dWidth == 0) {
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstp->dtypep()};
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstDTypep};
} else if (sWidth >= dWidth) {
srcp = new AstSel{streamp->fileline(), srcp, sWidth - dWidth, dWidth};
}
}
nodep->lhsp(dstp);
nodep->rhsp(srcp);
nodep->dtypep(dstp->dtypep());
nodep->dtypep(dstDTypep);
VL_DO_DANGLING(pushDeletep(streamp), streamp);
// Further reduce, any of the nodes may have more reductions.
return true;
} else if (m_doV && VN_IS(nodep->rhsp(), StreamL)) {
AstNodeDType* const lhsDtypep = nodep->lhsp()->dtypep();
AstNodeDType* const lhsDtypep = nodep->lhsp()->dtypep()->skipRefp();
AstStreamL* streamp = VN_AS(nodep->rhsp(), StreamL);
AstNodeExpr* const srcp = streamp->lhsp();
const AstNodeDType* const srcDTypep = srcp->dtypep();
const AstNodeDType* const srcDTypep = srcp->dtypep()->skipRefp();
if (VN_IS(srcDTypep, QueueDType) || VN_IS(srcDTypep, DynArrayDType)
|| VN_IS(srcDTypep, UnpackArrayDType)) {
streamp->lhsp(new AstCvtArrayToPacked{srcp->fileline(), srcp->unlinkFrBack(),
nodep->dtypep()});
streamp->lhsp(
new AstCvtArrayToPacked{srcp->fileline(), srcp->unlinkFrBack(), lhsDtypep});
streamp->dtypeFrom(lhsDtypep);
}
} else if (m_doV && replaceAssignMultiSel(nodep)) {
@@ -2266,6 +2269,19 @@ class ConstVisitor final : public VNVisitor {
}
return false;
}
bool replaceJumpGoNext(AstJumpGo* nodep, AstNode* abovep) {
// If JumpGo has an upper JumpBlock that is to same label, then
// code will by normal sequential operation do the JUMPGO and it
// can be removed.
if (nodep->nextp()) return false; // Label jumps other statements
AstJumpBlock* const aboveBlockp = VN_CAST(abovep, JumpBlock);
if (!aboveBlockp) return false;
if (aboveBlockp != nodep->labelp()->blockp()) return false;
if (aboveBlockp->endStmtsp() != nodep->labelp()) return false;
UINFO(4, "JUMPGO => last remove " << nodep << endl);
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
return true;
}
// Boolean replacements
bool operandBoolShift(const AstNode* nodep) {
@@ -2883,8 +2899,8 @@ class ConstVisitor final : public VNVisitor {
if (const AstConst* const aConstp = VN_CAST(ap, Const)) {
const AstConst* const bConstp = VN_AS(bp, Const);
if (aConstp->toUQuad() < bConstp->toUQuad()) return -1;
if (aConstp->toUQuad() > bConstp->toUQuad()) return 1;
if (aConstp->num().isLtXZ(bConstp->num())) return -1;
if (bConstp->num().isLtXZ(aConstp->num())) return 1;
return 0;
}
@@ -3158,8 +3174,9 @@ class ConstVisitor final : public VNVisitor {
nodep->condp(new AstLogAnd{lowerIfp->fileline(), condp, lowerCondp});
lowerIfp->replaceWith(lowerThensp);
VL_DO_DANGLING(pushDeletep(lowerIfp), lowerIfp);
} else if (operandBoolShift(nodep->condp())) {
replaceBoolShift(nodep->condp());
} else {
// Optimizations that don't reform the IF itself
if (operandBoolShift(nodep->condp())) replaceBoolShift(nodep->condp());
}
}
}
@@ -3235,7 +3252,7 @@ class ConstVisitor final : public VNVisitor {
}
}
if (m_doNConst && anyconst) {
// UINFO(9," Display in "<<nodep->text()<<endl);
// UINFO(9, " Display in " << nodep->text() << endl);
string newFormat;
string fmt;
bool inPct = false;
@@ -3251,9 +3268,9 @@ class ConstVisitor final : public VNVisitor {
inPct = false;
fmt += ch;
switch (std::tolower(ch)) {
case '%': break; // %% - just output a %
case 'm': break; // %m - auto insert "name"
case 'l': break; // %l - auto insert "library"
case '%': break; // %% - still %%
case 'm': break; // %m - still %m - auto insert "name"
case 'l': break; // %l - still %l - auto insert "library"
case 't': // FALLTHRU
case '^': // %t/%^ - don't know $timeformat so can't constify
if (argp) argp = argp->nextp();
@@ -3377,7 +3394,7 @@ class ConstVisitor final : public VNVisitor {
void visit(AstJumpGo* nodep) override {
iterateChildren(nodep);
// Jump to label where label immediately follows this go is not useful
// Jump to label where label immediately follows this JumpGo is not useful
if (nodep->labelp() == VN_CAST(nodep->nextp(), JumpLabel)) {
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
// Keep the label, might be other jumps pointing to it, gets cleaned later
@@ -3390,14 +3407,14 @@ class ConstVisitor final : public VNVisitor {
}
// If last statement in a jump label we have JumpLabel(...., JumpGo)
// Often caused by "return" in a Verilog function. The Go is pointless, remove.
if (replaceJumpGoNext(nodep, nodep->abovep())) return;
// Also optimize If with a then or else's final statement being this JumpGo
// We only do single ifs... Ideally we'd look at control flow and delete any
// Jumps where any following control flow point is the label
if (!nodep->nextp()) {
if (AstJumpBlock* const aboveBlockp = VN_CAST(nodep->abovep(), JumpBlock)) {
if (aboveBlockp == nodep->labelp()->blockp()) {
if (aboveBlockp->endStmtsp() == nodep->labelp()) {
UINFO(4, "JUMPGO => last remove " << nodep << endl);
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
return;
}
if (AstNodeIf* const aboveIfp = VN_CAST(nodep->abovep(), NodeIf)) {
if (!aboveIfp->nextp()) {
if (replaceJumpGoNext(nodep, aboveIfp->abovep())) return;
}
}
}
@@ -3857,7 +3874,7 @@ AstNode* V3Const::constifyParamsEdit(AstNode* nodep) {
} else {
nodep = visitor.mainAcceptEdit(nodep);
}
// Because we do edits, nodep links may get trashed and core dump this.
// Because we do edits, nodep links may get trashed and core dump if have next line
// if (debug() > 0) nodep->dumpTree("- forceConDONE: ");
return nodep;
}

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