Commit Graph

9880 Commits

Author SHA1 Message Date
Yilou Wang 3853301367
Fix disable iff ignored when its condition is held continuously true (#7841) 2026-06-26 06:00:44 -04:00
Geza Lore 2d157b29b0 Optimize assetOn checks furter 2026-06-25 20:12:49 +01:00
Yilou Wang f0f1c44dd6
Fix object randomization skipped by an unrelated global constraint (#7833) (#7838)
Fixes #7833.
2026-06-25 09:30:05 -04:00
Geza Lore b73a897db3
Optimize module inlining heuristic (#7837)
Rewrite module inlining decision to be based on a bipartite Module/Cell
graph, similar to V3InlineCFuncs. Preserved all old heuristics, but
added 2 new ones:

- If a module, and all the sub-hierarchy below it, is less than 10% the
  total flattened size of the design, then flatten the contents of that
  module (but the module itself is not necessarily inlined).

- If the flattened size of all instances of a module is less than 20% of
  the total flattened size of the design, then inline all instances of
  that module.

These are both relative to the total size of the design, so they
auto-scale with complexity. The net effect is that large shared
instances are preserved, but their contents are flattened out. E.g. in a
multi-core CPU this would keep the cores non-inlined but flatten out
most everything else. This still enables V3Combining and sharing those
later, but avoids potentially big overheads e.g. with small widely used
library modules.

Empirically this yields less generated C++ than the previous version
(due to removing lots of small functions), and can improve performance
10-20% while still having meaningful combining relative to the size of
the design.
2026-06-25 14:14:15 +01:00
Yilou Wang 000afcf52d
Support variable-length intersect in SVA sequences (#7835) 2026-06-25 04:41:53 -07:00
github action 0ebae43713 Apply 'make format' [ci skip] 2026-06-25 02:44:28 +00:00
Wolfgang Mayerwieser 249608a42f
Fix performance on large package-scoped structs (#7830) 2026-06-24 19:43:24 -07:00
Ryszard Rozak def1e2ccbc
Fix lifetime of expression coverage variable (#7834)
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
2026-06-24 09:59:32 -04:00
Yilou Wang 9462c2a910
Fix unclocked concurrent assertion misreported as unsupported (#7831) 2026-06-24 09:44:47 -04:00
Matthew Ballance d456384d39
Support hierarchical reference cross members (#7749) (#7820) 2026-06-24 07:47:36 -04:00
Ryszard Rozak 995534d3ed
Fix insertion of expression coverage statement (#7832)
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
2026-06-24 07:44:49 -04:00
Artur Bieniek 350158c857
Fix scheduling of virtual interface method writes (#7641)
Fix scheduling of writes in virtual interfaces, there were missing triggers (see added test).

Make V3SchedVirtIface handle writes done inside methods called through a virtual interface. The pass first records direct vif.member writes, VIF method calls, and candidate interface member VarScopes. It then walks the methods reachable from those VIF calls, writes to persistent interface variables in those method bodies are treated as VIF writes, and nested calls are followed with the same interface context. Function locals, temps, and events are ignored because they are not persistent interface storage observable through a later VIF read. Triggers are still created only from the intersection of (interface type, member name) writes and matching VarScopes, so unrelated interface variables and interfaces with no virtual access do not get extra triggers.
2026-06-24 10:51:42 +01:00
github action 84cc08b756 Apply 'make format' [ci skip] 2026-06-24 09:44:11 +00:00
Thomas Santerre bd6b9161dc
Optimize bit-scan loops into $mostsetbitp1 / $countones (#7822)
Recognize the common single-bit scan loop idioms in V3Unroll (before it
unrolls) and lower them to bit-reduction primitives, replacing a literal
W-iteration loop with one intrinsic-backed expression:

  target=0; for (i=0;i<W;i++) if (vec[i]) target = i + 1;      -> $mostsetbitp1(vec)
  target=0; for (i=0;i<W;i++) if (vec[i]) target = target + 1; -> $countones(vec)

The leading-one form lowers to a new AstMostSetBitP1 node, emitted as
VL_MOSTSETBITP1_{I,Q,W}; those runtime helpers now use __builtin_clz where
available (same pattern as VL_REDXOR's __builtin_parity), with the existing
bit scan as fallback.  The count-ones form reuses AstCountOnes ($countones,
popcount); as the DFG requires a 32-bit countones result it is built at 32
bits and narrowed to the accumulator width with a select.

Matching is structural to stay sound: the index must start at 0, increment
by exactly 1, and scan all W==width(vec) bits via a single 1-bit select of a
distinct vector, with the target pre-zeroed and no else branch.  The loop
bound is accepted as a strict ascending 'idx < W' written either way and
signed or unsigned (Gt/GtS/Lt/LtS).  Gated by -fbit-scan-loops (on at -O).

Adds t_bit_scan_loops (I/Q/W, count-ones and unsigned-index positives;
step-2, start-1, idx*2+1, vec[idx+1], target=idx and W!=width negatives, all
self-checked and asserted via --stats not to lower) plus t_bit_scan_loops_off
for the disable flag.

Motivated by a transformer inference design whose 80-bit leading-one detector
ran every cycle (~37% of runtime); the lowering is worth ~39% there.
2026-06-24 10:43:05 +01:00
Wilson Snyder 7752625f49 CI: Pin actions to hashes 2026-06-23 21:24:21 -04:00
Wilson Snyder 36d30d8fcb CI: Remove unused passed step 2026-06-23 21:21:07 -04:00
Tom Jackson 2baca68f86
Fix class/var named identically to an enclosing-scope type (#7827) (#7828)
Fixes #7827.
2026-06-23 20:43:31 -04:00
Igor Zaworski 0cd13f80c9
Fix nested class split crash (#7826)
Signed-off-by: Igor Zaworski <izaworski@antmicro.com>
2026-06-23 14:07:15 -04:00
Jakub Wasilewski d5c040d8e6
Fix skewed dist operator for arrays (#7802) 2026-06-23 09:47:55 -04:00
Nick Brereton 6fbc7042a5
Support VPI access to unpacked struct members (#7823) 2026-06-23 07:04:51 -04:00
Geza Lore c76c94ef16
Optimize additional expression patterns in V3Const (#7824)
- Masking that returns known zero
- More general Sel over Extend
2026-06-23 04:22:35 +01:00
Matthew Ballance 756bcf5742
Fix '$' as unsupported coverpoint-bin range bounds (#7750) (#7825) 2026-06-22 22:14:43 -04:00
Artur Bieniek 87bebbb732
Support global $assertcontrol (#7807)
Signed-off-by: Artur Bieniek <abieniek@antmicro.com>
2026-06-22 18:51:41 -04:00
Wilson Snyder c927f05f35 Update fst from upstream (#6771 partial) 2026-06-22 17:25:59 -04:00
dependabot[bot] bf50baefee
CI: Bump actions/checkout from 6 to 7 in the everything group (#7821) 2026-06-22 12:48:29 -04:00
github action 515c4282f4 Apply 'make format' [ci skip] 2026-06-22 16:47:50 +00:00
Saksham 729794bc0e
Fix CASEINCOMPLETE for all uncovered enum items (#7815) (#7817)
Fixes #7815.
2026-06-22 12:41:48 -04:00
Geza Lore 7765738e11
Internals: Do not generate redundant masking on word selects (#7819)
newAstWordSelClone returns a clean word and these And mask out exactly
the bits that are zero after the shift.
2026-06-22 16:42:22 +01:00
Geza Lore 9670dabcfe Internals: Keep separate stats for constant pool variables 2026-06-22 10:15:49 +01:00
Geza Lore b37c84109d
Optimize staticly known oversize shifts (#7806)
The non *Ovr flavours of AstShift* have better downstream constant
folding, so keep using those if proven safe. Fold overshifts explicitly
instead of introducing *Ovr shifts.
2026-06-22 10:06:26 +01:00
Geza Lore fed922a538 Internals: Compact stage statistics table 2026-06-22 09:39:53 +01:00
Geza Lore eafe9636cf
Internals: Dump Ast expression pattern statistics like Dfg (#7818)
Remove the expression combination counts from the default stats file,
and add a new `--dump-ast-patterns` option, which will dump new
`*_ast_patterns_*.txt` files. These contain the expression combinations
in a similar S-expression format as Dfg already produces with
`--dump-dfg-stats`. These dumps are not produced by just `--stats` as
they are fairly expensive to compute. Currently the new option will dump
at two points: just before we change to C types via widthMin usage, and
just before emit.
2026-06-21 22:17:36 +01:00
Geza Lore fbea10b427 Internals: Fix dumping of fast-only statistics after emit 2026-06-21 19:10:38 +01:00
Wilson Snyder 78a2dc0738
CI/Makefile: Auto format .rst files (#7816)
Maintainers: Note this requires a `make venv` to get docstrfmt==2.2.0
2026-06-21 13:53:00 -04:00
Geza Lore bcaa110f60
Optimize generated function inlining (#7811)
Previously V3InlineCFuncs inlined call sites but never deleted the now
dead callees. Also missed a lot of opportunities due to evaluation order.

Rewrite using a graph based algorithm, using only a single traversal of
the netlist. This is clearer, more accurate, and faster at compile time.

Also add a clean -fno-inline-cfuncs disable. Setting the limits to 0
still disables inlining, except of empty functions, which can be inlined
with 0 limits (they are no ops). It will also prune unused functions
without -fno-inline-cfuncs.

Pass now also respects `--output-split`
2026-06-21 18:31:56 +01:00
Wilson Snyder 5fc03ae913 Commentary: Make RST documents round-trip clean. No output change intended. 2026-06-21 10:15:47 -04:00
Wilson Snyder b92bf86016 Commentary: Changes update 2026-06-21 10:14:53 -04:00
Geza Lore e1f1a50327 Fix assertion when loop unrolling failed (#7810)
Partial fix for #7810
2026-06-21 10:28:23 +01:00
Igor Zaworski e269b914b2
Support NBAs in initial blocks (#7754) 2026-06-20 17:23:05 -04:00
Wilson Snyder 047d6e03d9 Tests: Add t_sys_file_scan_delay (#4811) 2026-06-20 07:47:44 -04:00
Wilson Snyder 78d96d23ee Commentary (#7809) 2026-06-20 06:45:51 -04:00
Wilson Snyder d66f96e246 Commentary: Changes update 2026-06-20 06:45:04 -04:00
Geza Lore 9a231d254d
Optimize Dfg cycle breaking to do less work (#7210)
When a vertex is made acyclic, conservatively update the SCC map to
propagate and mark connected vertices as acyclic as much as possible.
This way we can stop early if the graph becomes acyclic after some
fixups. This can significantly reduce the number of fixups needing to be
applied, avoiding introducing redundancy.
2026-06-19 22:28:50 +01:00
Geza Lore a37e2ee94b
Optimize wide decoder case statements into decoder expressions (#7804)
Extend the decoder-pattern case optimization to selectors that are too
wide for a full 2^width lookup table. A decoder-pattern case (where
every case item assigns constants to a fixed set of LHSs) is lowered to
a new AstMachMasked expression. AstMachMasked is emitted as a run-time
VL_MATCHMASKEd_* function call. It contains a packed constant pool table,
'matchp', which is a list of '(mask, bits)' pairs. At runtime, the index of the 
first matching entry is returned, and is used to index a value table. This single
(albeit complicated) expression can replace large if-else trees whole, resulting
in much more compact code with fewer static hard to predict branches. It
is worth about 10% speed and 30% code size in some designs.

Example:

```systemverilog
    logic [39:0] sel;
    always_comb
      casez (sel)
        40'b???????????????????????????????????????1: out = 8'h01;
        40'b??????????????????????????????????????1?: out = 8'h02;
        40'b?????????????????????????????????????1??: out = 8'h03;
        default:                                      out = 8'hff;
      endcase
```

is compiled to:

```c++
    out = TABLE_value[VL_MATCHMASKED_Q(sel, CONST_match)];
```

Where 'CONST_match' contains 4 entries, of a 40-bit mask and 40-bit bit
pattern each, and 'TABLE_value' contains 4 entries of the corresponding
8-bit results. (Entries are aligned to word boundaries to avoid runtime
bit swizzling)
2026-06-19 19:46:13 +01:00
Yilou Wang 59fba72cb6
Support method calls on a sub-interface via a virtual interface (#7800) 2026-06-19 08:41:48 -04:00
Wilson Snyder 749b93e405 Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
Wilson Snyder 50c15f3705 Commentary: Changes update 2026-06-18 21:56:02 -04:00
Yilou Wang 129cfc19c0
Fix cross-hierarchy tristate drivers of interface nets (#7339) (#7801)
Closes #7339.
2026-06-18 19:07:37 -04:00
Artur Bieniek 51022d6152
Tests: Fix unstable --vltmt test (#7803)
Fixes #7803.
2026-06-18 14:40:54 -04:00
Yilou Wang a5a16cfbfd
Support unbounded always [m:$] and strong s_always liveness (#7798) 2026-06-18 11:17:09 -04:00