Commit Graph

8367 Commits

Author SHA1 Message Date
Szymon Gizler 8868d459a2
Fix broken support of unassigned virtual interfaces (#6253) (#6338)
* Fix broken support of unassigned virtual interfaces

Unassigned virtual interface support added by #6245 is broken - PR marks
dead module as alive - we can't do that as once a module is dead it
needs to remain dead because earlier steps (e.g. port resolution) have
already been skipped.

This commit handles unassigned virtual interfaces at the beginning of
first pass of LinkDot (so it is never marked as dead, and no linking
steps are getting skipped).

Fixes #6253.

* Apply suggestions from code review

Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>

* Apply 'make format'

* Revert add of redundant iterateChildren() call

* Add original test case

---------

Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>
Co-authored-by: github action <action@example.com>
2025-08-28 09:03:46 -04:00
Geza Lore 1043a6c6be
Fix splitting of assignments to SC variables (#6329) (#6336)
SC variables can only be assigned whole, so do not split up
concatenation assignments in V3FuncOpt.

Fixes #6329
2025-08-28 08:48:51 +01:00
Wilson Snyder 409e036eca Add error on gate primitive connection width mismatch 2025-08-27 22:28:09 -04:00
Wilson Snyder e32108713d Fix randomize on function-local variable (#6234). 2025-08-27 21:25:40 -04:00
Wilson Snyder 54efa86a6c Fix error on too many UDP port inputs 2025-08-27 07:48:33 -04:00
Ryszard Rozak ac21d25d43
Support simple disable within task (#6334) 2025-08-26 10:39:24 -04:00
Geza Lore a841a962ce
Optimize interfaces in Dfg (#6332)
Interfaces that have no corresponding virtual interface references can
be safely optimized by Dfg after V3Scope. Enabling it to do so.
2025-08-26 11:24:15 +01:00
Wilson Snyder 5f23bf95f6 Internals: Refactor V3EmitUtil to not be base class. No functional change. 2025-08-25 22:05:40 -04:00
Wilson Snyder ac2859bf24
Internals: Upgrade to clang-format-18 (#6333) 2025-08-25 20:47:48 -04:00
Wilson Snyder 703f0d8c5d Commentary: spelling 2025-08-25 18:47:08 -04:00
Wilson Snyder 3d76bb9944 Commentary: Changes update 2025-08-25 17:50:29 -04:00
Geza Lore 02e64f0795
Optimize multiplexers in Dfg synthesis (#6331)
The previous algorithm was designed to handle the general case where a
full control flow path predicate is required to select which value to
use when synthesizing control flow join point in an always block.

Here we add a better algorithm that tries to use the predicate of
the closest dominating branch if the branch paths dominate the joining
paths. This is almost universally true in synthesizable logic (RTLMeter
has no exceptions), however there are cases where this is not
applicable, for which we fall back on the previous generic algorithm.

Overall this significantly simplifies the synthesized Dfg graphs and
enables further optimization.
2025-08-25 13:47:45 +01:00
Igor Zaworski c2cac8a7fd
Fix of localize for super constructors with function calls as arguments (#6330) 2025-08-25 06:55:11 -04:00
Wilson Snyder ac2a75fbb5 Support future sampled value functions. 2025-08-23 21:16:53 -04:00
Wilson Snyder 7affb3e580 Internals: Add $past variable statistic 2025-08-23 21:10:46 -04:00
Wilson Snyder b226be7f98 Fix to select UDPs when they are the only candidate for a top module. 2025-08-23 15:20:58 -04:00
Wilson Snyder f45b811c22 Commentary: Changes update 2025-08-23 15:20:36 -04:00
Aleksander Kiryk ee1ab074dc
Internals: Fix missing variable initializations (#6327) 2025-08-23 10:59:12 -04:00
Aleksander Kiryk a9aa2f11b8
Improve testing on FreeBSD (#6328)
* Skip profiling tests on non-glibc platforms

* Enforce dumb terminal in tests

* Include POSIX headers whenever __unix__ macro is defined

* Treat no procfs as normal condition

* Respect MAKE variable when running make
2025-08-23 10:49:03 -04:00
Aleksander Kiryk 353a2e3d20
Fix gathering senaitivities from virtual interface members (#6325) 2025-08-23 10:45:13 -04:00
Aleksander Kiryk 34315a4f70
Fix FreeBSD missing headers (#6326)
* Include missing libgen.h

* Include missing cinttypes
2025-08-23 10:38:18 -04:00
Aleksander Kiryk d56d1a7719
Fix queue extend to check bounds (#6324) 2025-08-23 10:37:40 -04:00
Geza Lore 1c86ff0af2
Fix corner case bugs in module and variable inlining (#6322)
There were a couple corner case bugs in V3Inline, and one in Dfg when
dealing with inlining of modules/variables.

V3Inline:
- Invalid code generated when inlining an input that also had an
  assignment to it (Throws an ASSIGNIN, but this is sometimes reasonable
  to do, e.g. hiererchical reference to an unonnected input port)
- Inlining (aliasing) publicly writeable input port.
- Inlining forcable port connected to constant.

Dfg:
- Inining publicly writeable variables

The tests that cover these are the same and fixing one will trigger the
other bug, so fixing them all in one go. Also cleanup V3Inline to be less
out of order and rely less on unique APIs only used by V3Inine (will
remove those in follow up patch).

Small step towards #6280.
2025-08-22 21:43:49 +01:00
Igor Zaworski f506aa878b
Fix of inline constraints with member selects (#6321) 2025-08-22 07:58:03 -04:00
Igor Zaworski b95a974ff1
Support generic interfaces (#6272) 2025-08-22 06:44:35 -04:00
Artur Bieniek b19215770b
Fix direct NBA to dynamically-sized variable (#6310) 2025-08-22 06:21:13 -04:00
Wilson Snyder 457fcc267b Support elaboration-time printing of unpacked array with `%p` (#4732). 2025-08-21 21:44:31 -04:00
Wilson Snyder e202cb31d8 Change `$display("%p")` to remove space after `}`. 2025-08-21 21:33:05 -04:00
Wilson Snyder b96f35b8fe Internals: Add AstToStringN (#4732 prep) 2025-08-21 21:09:10 -04:00
Wilson Snyder 997d5ecdf1 Internals: Cleanup cppcheck c casts. No functional change intended. 2025-08-21 20:06:43 -04:00
Igor Zaworski 631714c50a
Fix expression type comparison (#6316) 2025-08-21 06:26:30 -04:00
Geza Lore 327d55d13d
Internals: Fix remaining cppcheck errors (#6319)
Fixed the non const-related issue and added suppressions for the const
ones. With that `make cppcheck` should be clean.
2025-08-21 09:43:37 +01:00
Wilson Snyder bd91b619ad Support `$fread` with missing start (#6125). 2025-08-20 21:19:42 -04:00
Wilson Snyder dc5a17fea0 Support unpacked array `with` methods (#6134). 2025-08-20 21:01:34 -04:00
Wilson Snyder 254eb407ff Commentary: Changes update 2025-08-20 21:00:40 -04:00
Geza Lore 92d47ca23a
Internals: Add separate cppcheck targets for whole components (#6318)
cppcheck provides best results when analysing the whole program. It also
has a builtin `-j` option to run on multiple threads.

Replace existing cppcheck-* targets with cppcheck-verilator,
cppcheck-runtime, cppcheck-example and cppcheck-vlc that checks each of
those components as a whole. Each of these runs on the maximum available
logical processors on the host by default, as reported by `nproc`, but
can be manually overridden with `make CPPCHECK_JOBS=<number>` instead.

The `make cppcheck` target runs the 4 cppcheck-* targets listed above
sequentially (but each of them uses the specified CPPCHECK_JOBS threads)
2025-08-20 13:49:59 -04:00
Geza Lore 67da797816
Internals: Cleanup cppcheck warnings (#6317)
`make cppcheck-4` is now clean.
2025-08-20 18:21:24 +01:00
Ryszard Rozak 3d3462b209
Support disabling a fork from within that fork (#6314) 2025-08-20 12:21:07 -04:00
Igor Zaworski 11667160f2
Fix static vars under member select (#6313) 2025-08-20 11:23:16 -04:00
Ryszard Rozak 95c8b7bb00
Support separate coverage counters for toggles 0->1 and 1->0 (#6086) 2025-08-20 07:31:04 -04:00
Wilson Snyder 9b2f55ab39 Internals: Fix up include/ cppcheck issues (#6311) 2025-08-20 07:27:55 -04:00
Wilson Snyder f71b8e6195 Internals: Fix up include/ cppcheck issues (#6311) 2025-08-19 21:36:52 -04:00
Geza Lore d1f71f2342
Internals: Improve V3Rtti for cppcheck (#6312)
Rewrite with much less running around in the templates. Use private
methods only + friend functions that do the actual type check. This
avoids cppcheck warnings.
2025-08-19 23:05:34 +01:00
Geza Lore a0edd4e907
Internals: Improve cppcheck flow and fix up issues (#6311)
Added cppcheck-suppressions.txt in the repo root. You can add new
patterns in there instead of having to parse the XML output.

Also configure to add the -D__GNUC__ preprocessor macro, which makes it
understand UASSERT (it understands the 'noreturn' function attribute).

Added some case by case specific suppressions and fixed up other code,
especially in V3Ast*h and V3Dfg*.h, including code generated by astgen
that had some no-ops that irks cppcheck.

One thing it does not seem to like is `const` class members with default
initializers in the class. It will assume that's always the value, even
if overridden in the constructor. We had few so removed them.

With that a lot of files in `src/` are now clean or only have a handful
of issues. Therefore, I have also deleted cppcheck_filtered, and made it
produce human readable output straight to the terminal.

Regarding cleaning up the reported nits, I kind of got bored after
V3[A-E] so pausing here. Apologies for the merge conflicts.

Tested with cppcheck 2.13.0
2025-08-19 22:02:10 +01:00
Geza Lore 636a6b8cd2
Optimize complex combinational logic in DFG (#6298)
This patch adds DfgLogic, which is a vertex that represents a whole,
arbitrarily complex combinational AstAlways or AstAssignW in the
DfgGraph.

Implementing this requires computing the variables live at entry to the
AstAlways (variables read by the block), so there is a new
ControlFlowGraph data structure and a classical data-flow analysis based
live variable analysis to do that at the variable level (as opposed to
bit/element level).

The actual CFG construction and live variable analysis is best effort,
and might fail for currently unhandled constructs or data types. This
can be extended later.

V3DfgAstToDfg is changed to convert the Ast into an initial DfgGraph
containing only DfgLogic, DfgVertexSplice and DfgVertexVar vertices.

The DfgLogic are then subsequently synthesized into primitive operations
by the new V3DfgSynthesize pass, which is a combination of the old
V3DfgAstToDfg conversion and new code to handle AstAlways blocks with
complex flow control.

V3DfgSynthesize by default will synthesize roughly the same constructs
as V3DfgAstToDfg used to handle before, plus any logic that is part of a
combinational cycle within the DfgGraph. This enables breaking up these
cycles, for which there are extensions to V3DfgBreakCycles in this patch
as well. V3DfgSynthesize will then delete all non synthesized or non
synthesizable DfgLogic vertices and the rest of the Dfg pipeline is
identical, with minor changes to adjust for the changed representation.

Because with this change we can now eliminate many more UNOPTFLAT, DFG
has been disabled in all the tests that specifically target testing the
scheduling and reporting of circular combinational logic.
2025-08-19 15:06:38 +01:00
Geza Lore 6a67c0a0e5
Iternals: Fix AstSplitPlaceholder, it is a statement (#6280) (#6309) 2025-08-19 11:14:28 +01:00
Geza Lore 6b9cc8a36e
Internals: Fix AstNodeCoverDecl, it is not a statement (#6280) (#6308) 2025-08-19 11:14:17 +01:00
Geza Lore 0bf9fc270f
Iternals: Remove AstAssignPre/AstAssignPost (#6307)
Replace with AstAlwaysPre/AstAlwaysPost with AstAssign under them.

Step towards #6280
2025-08-19 09:27:59 +01:00
Geza Lore c9a6d06544
Improve V3LifePost to not require AstAssignPre/AssignPost (#6306)
Rewrote V3LifePost to not depend on having AstAssignPre and
AstAssignPost types, but work with generic AstNodeAssign. There is an
extra flag in AstVarScope to denote it's part of an NBA and should be
considered.

Step towards #6280.
2025-08-19 00:11:14 +01:00
Wilson Snyder c90f9e53b7
Add ALWNEVER warning, for `always @*` that never execute (#6291) (#6303) 2025-08-18 12:00:53 -04:00