Commit Graph

8649 Commits

Author SHA1 Message Date
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
Artur Bieniek 53c59e7ac7
Fix referencing module variables above classes (#6304)
Signed-off-by: Artur Bieniek <abieniek@internships.antmicro.com>
2025-08-18 08:51:25 -04:00
Geza Lore 9dc31e4556
Fix unsound assertion in V3Delayed (#6305) 2025-08-18 13:46:35 +01:00
Geza Lore c172cc2ab0
Internals: Simplify port connect after instance dearray (#6302)
Pre pull for #6298
2025-08-18 09:55:54 +01:00
Wilson Snyder 25d71a43a5 For hier-generated Verilog, use always_comb 2025-08-17 20:14:19 -04:00
Wilson Snyder 88046c8063 Internals: Rename AstSenTree pointers to sentreep. No functional change intended except JSON. 2025-08-17 19:14:34 -04:00
Wilson Snyder dbdf235115 Commentary: Changes update 2025-08-17 14:53:59 -04:00
Wilson Snyder eaecdf7477 Tests: Improve check for member brace initialization. 2025-08-17 14:40:10 -04:00
Geza Lore f6edf26eb2
Fix hierarchical NBAs (#6286) (#6300)
NBAs targeting a variable in a different scope are now allocated
temporary variables for captured values in the scope of the NBA, not the
scope of the target variable.

Fixes #6286
2025-08-17 19:35:40 +01:00
Wilson Snyder b14539569f Internals: Check and enforce member brace initialization. No functional change intended 2025-08-17 13:20:52 -04:00
Wilson Snyder 7126293086 Support enum.next with a parameter 2025-08-16 21:06:35 -04:00
Wilson Snyder 36c4a24661 Internals: constifyParamsEdit return value was unused. No functional change. 2025-08-16 21:03:12 -04:00
Wilson Snyder 49ca1cfdd7 Commentary 2025-08-16 18:32:40 -04:00
Wilson Snyder 48a12fb0f4 Document and test `+verilator+rand+reset+2` usage (#6285 partial) 2025-08-16 11:47:19 -04:00
Wilson Snyder 340d1aff4a Tests: Cleanup to favor '--binary'. No test change intended. 2025-08-16 09:26:42 -04:00
Wilson Snyder 000d697b51 Commentary: Changes update 2025-08-16 09:08:09 -04:00
Geza Lore a300bfc538
Internals: Add AstNodeStmt.h (#6295)
Move AstNodeStmt and all its subtypes into AstNodeStmt.h.

This is the first step for #6280.

No functional change
2025-08-16 09:46:18 +01:00
Geza Lore 6f69c990fd
Internals: Remove AstCondBound and AstNodeCond (#6293) (#6294)
Fixes #6293
2025-08-15 15:49:06 -07:00
Geza Lore d273e2cbd0 Internals: Do not astgen useless Dfg vertex subtypes 2025-08-15 20:06:58 +01:00