Commit Graph

5294 Commits

Author SHA1 Message Date
Geza Lore 7a3f1f16ca
Optimize DFG before V3Gate (#6141) 2025-07-01 17:55:08 -04:00
Wilson Snyder e015805194 Fix stripping on randomize (#6144 partial) 2025-07-01 08:57:08 -04:00
Wilson Snyder 9598ef9315 Internals: Avoid - in enum name 2025-07-01 05:45:10 -04:00
Wilson Snyder cd0f35fe67 Fix recursive module assertion, broken recent lib commit (#5891 partial fix) 2025-06-30 20:30:27 -04:00
Wilson Snyder d455ec6229 Fix `specparam` PATHPULSE broken recent commit (#6142). 2025-06-30 18:33:50 -04:00
github action b27bd6526a Apply 'make format' 2025-06-30 01:00:56 +00:00
Wilson Snyder 916a89761e Add `--work` library-selection option (#5891 partial). 2025-06-29 20:17:27 -04:00
Geza Lore c3d86626ee
Internals: Remove unused AstNodeModule 'activesp' child (#6138) 2025-06-29 09:56:44 -04:00
Wilson Snyder 5d32fc56ac Support 'config' parsing, but not functionally 2025-06-28 20:32:19 -04:00
Wilson Snyder 93f447dd4a Support constant functions with left-hand-side concatenates. 2025-06-28 17:12:03 -04:00
Geza Lore bc892deacc
Safely support non-overlapping blocking/non-blocking assignments (#6137)
The manual for the BLKANDNBLK warning describes that it is safe to
disable that error if the updated ranges are non-overlapping. This
however was not true (see the added t_nba_mixed_update* tests).

In this patch we change V3Delayed to use a new ShadowVarMasked
scheme for variables that have mixed blocking and non-blocking 
updates (or the FlagUnique scheme for unpacked variables), which
is in fact safe to use when the updated parts are non-overlapping.

Furthermore, mixed assignments are safe as far as scheduling is
concerned if either:

- They are to independent parts (bits/members/etc) (with this patch)
- Or if the blocking assignment is in clocked (or suspendable) logic.

The risk in scheduling is a race between the Post scheduled NBA
commit, and blocking assignments in combinational logic, which might
order incorrectly.

The second point highlights that we can handle stuff like this safely,
which is sometimes used in testbenches:

```systemverilog
always @(posedge clk) begin
    if ($time == 0) a = 0;
end

always @(posedge clk) begin
    if ($time > 0) a <= 2;
end
````

The only dangerous case is:

```systemverilog
always @(posedge clk) foo[idx] <= val;
assign foo[0] = bar;
```

Whit this patch, this will still resolve fine at run-time if 'idx' is
never zero, but might resolve incorrectly if 'idx' is zero.

With the above in mind, the BLKANDNBLK warning is now only issued if:

- We can't prove that the assignments are to non-overlapping bits
- And the blocking assignment is in combinational logic

These are the cases that genuinely require user attention to resolve.

With this patch, there are no more BLKANDNBLK warnings in the RTLMeter
designs.

Fixes #6122.
2025-06-28 20:45:45 +01:00
Wilson Snyder b914cda1c7 Internals: cppcheck cleanups. No functional change. 2025-06-28 12:29:41 -04:00
Wilson Snyder 62e5e3aa0c Fix interface array connections with non-zero low declaration index. 2025-06-28 09:43:02 -04:00
Wilson Snyder f508dadc97 Support `specparam` (#5767). 2025-06-28 08:23:43 -04:00
Wilson Snyder 3defaf8ffb Rename Verilator Config Files to Verilator Control Files.
Avoids conflict with IEEE `config`.  No functional change intended.
2025-06-27 20:38:01 -04:00
Wilson Snyder 75229cc03d Fix `pre_randomize`/`post_randomize` when no randomize (#6122). 2025-06-26 18:34:20 -04:00
Wilson Snyder e422c183ff Fix method calls without parenthesis (#6127). 2025-06-26 18:16:21 -04:00
Wilson Snyder 2c5e9a785a Standardize indent of emitted makefile 2025-06-26 17:36:15 -04:00
Kamil Rakoczy d183b4edde
Fix variables declared in fork after taskify (#6126) 2025-06-26 10:28:58 -04:00
Wilson Snyder 2df0390c04 Commentary 2025-06-25 21:14:25 -04:00
Wilson Snyder 3209bee3b3 Fix colon-divide operator without space (#6121). 2025-06-25 04:56:52 -04:00
Wilson Snyder 51545b36ca Internals: Add format-make rule and standardize Makefile indents. No functional change intended. 2025-06-24 17:58:55 -04:00
Wilson Snyder 6af694b04b Support `$timeformat` with missing arguments (#6113). 2025-06-24 17:30:05 -04:00
Wilson Snyder f9f70383fa Fix instability in non-data type internal error 2025-06-24 17:29:44 -04:00
Geza Lore 916d473eff
Internals: Replace unnecessary AstSel::widthp() child node with const in node (#6117) 2025-06-24 11:59:09 -04:00
Wilson Snyder 544cb4a90f Fix decoding octal string escapes with 1-2 digits (#6108). 2025-06-23 18:37:44 -04:00
Geza Lore 2daa09a255
Optimize constify within Expand and Subst (#6111)
These passes blow up the Ast size on some designs, so delaying running V3Const
until after the whole pass can notably increase peak memory usage. In this
patch we apply V3Const per CFunc within these passes, which saves on memory.
Added -fno-const-eager to disable the intra-pass V3Const application, for
debugging.
2025-06-23 17:58:26 -04:00
Geza Lore d35e4a2b60
Improve memory usage for SenTrees in V3OrderProcessDomains (#6112) 2025-06-23 14:22:10 -04:00
Wilson Snyder 49fe129634 Fix `--lib-create` with double-underscore (#6099). 2025-06-18 08:56:32 -04:00
Peter Birch 75df36bc8f
Add hint of the signed rhsval in oversized replication error (#6098) 2025-06-17 16:59:18 -07:00
Geza Lore 48600c77b5
Fix DFG binToOneHot table index missing driver (#6100) 2025-06-17 15:53:47 +01:00
Geza Lore 277611bcdd
Add DFG binToOneHot pass to generate one-hot decoders (#6096)
Somewhat commonly, there is code out there that compares an expression (or
variable) against many different constants, e.g. a one-hot decoder:

```systemverilog
  assign oneHot = {x == 3, x == 2, x == 1, x == 0};
```

If the width of the expression is sufficiently large, this can blow up
a GCC pass and take an egregious amount of memory and time to compile.

Adding a new DFG pass that will generate a cheap one-hot decoder:
to compute:

```systemverilog
  wire [$bits(x)-1:0] idx = <the expression being compared many times>
  reg tab [1<<$bits(x)] = '{default: 0};
  reg [$bits(x)-1:0] pre = '0;

  always_comb begin
    tab[pre] = 0;
    tab[idx] = 1;
    pre = idx ; // This assignment marked to avoid a false UNOPFTLAT
  end
```

We then replace the comparisons `x == CONST` with `tab[CONST]`.

This is generally performance neutral, but avoids the compile time and memory
blowup with GCC (128GB+ -> 1GB in one example).

We do not apply this if the comparisons seem to be part of a `COMPARE ?
val : COND` conditional tree, which the C++ compilers can turn into jump
tables.

This enables all XiangShan configurations from RTLMeter to now build with GCC,
so in this patch we enabled those in the nightly runs.
2025-06-16 23:14:24 +01:00
Geza Lore 832629c602
Internals: Refactor DFG getCanonicalVariable for reusability (#6094)
This changes hashed names in the generated code, but otherwise no
functional change.
2025-06-16 07:25:44 -04:00
Geza Lore 5e5b5ab69d
Restrict Dfg PUSH_SEL_THROUGH_CONCAT pattern (#6092)
This pattern is bit dubious and can blow up the size of the logic.
Restrict it to only apply if it strictly does not increase DFG size.
2025-06-15 18:10:42 -04:00
Geza Lore d059806dbd
Fix Dfg eliminateVar pass to remove more variables (#6091)
Failing to reset the work list pointer in vertices leads to not removing
some redundant variables if they become redundant after having been
considered once already.
2025-06-15 18:12:37 +01:00
Geza Lore bca2e2c16e
Optimize DFG De Morgan patterns (#6090)
It's ok if the replaced vertex has multiple sinks, this pattern cannot
increase the size of logic even then.
2025-06-15 11:00:11 -04:00
Todd Strader 47f5a6a52b
Fix unpacked to packed parameter assignment (#6088) (#6081) 2025-06-12 12:47:58 -04:00
Todd Strader 206a0b4fd2
Fix casting reals to large integrals (#6085) 2025-06-12 11:53:10 -04:00
Bartłomiej Chmiel dc307270f7
Fix nested hier blocks workers error (#6087)
Signed-off-by: Bartłomiej Chmiel <bchmiel@antmicro.com>
2025-06-12 07:15:46 -04:00
Wilson Snyder 4990b44120 Fix trace hierarchicalName runtime errors (#5668) (#6076). 2025-06-10 20:17:32 -04:00
Paul Swirhun 4925f9ad73
Support 1-bit params with -G and -pvalue (#6051) (#6082) 2025-06-10 17:39:13 -04:00
Kamil Rakoczy 58ea7ad361
Fix class typedef elaboration (#6080) 2025-06-10 12:03:26 -04:00
Wilson Snyder b553502d8a Fix number dumps to show 'null' 2025-06-10 08:17:45 -04:00
Bartłomiej Chmiel 86d2ea8c70
Optimize DPI temporary 'for' loop performance (#6079)
Signed-off-by: Bartłomiej Chmiel <bchmiel@antmicro.com>
2025-06-10 08:17:26 -04:00
Todd Strader d9534ec626
Fix x assign vs init randomization (#6075) 2025-06-09 17:59:01 -04:00
Geza Lore a6bae7f196
DFG peephole: Only push SEL through COND when SEL is the only sink. (#6071)
This avoids potential O(n) logic duplication where 'n' is the fanout of
the COND node.

Fixes #6064.
2025-06-08 11:12:39 +01:00
Wilson Snyder 5b2dc52681 Fix array bounds checking with class member selects (#5996) (#5997). 2025-06-07 17:20:48 -04:00
Todd Strader a044697990
Fix signed cast (#6912) (#6068) 2025-06-06 21:13:31 -04:00
Wilson Snyder 54e637c72b Fix `--skip-identical` skipping on some errors (#6066). 2025-06-06 17:18:02 -04:00
Todd Strader d49efa79df
Fix type operator for interface signals (#6050) (#6049) 2025-06-06 11:29:33 -04:00
Wilson Snyder ed46878f7b Fix virtual interface array typedef expressions (#6057). 2025-06-04 21:43:46 -04:00
Wilson Snyder 593da4e38f Internals: Fix missing const. No functional change. 2025-06-04 21:43:30 -04:00
Todd Strader cfbcfd913c
Fix packed array deduction (#6046) 2025-05-31 07:55:00 -04:00
Wilson Snyder 79de1ff507 Fix WIDTHCONCAT on packed pattern assignment (#6045). 2025-05-31 07:38:15 -04:00
Nick Brereton 8a8f04153a
Fix method calls and new to access interface arrays (#5973) 2025-05-29 22:11:47 -04:00
Wilson Snyder 8031ca2616 Add `MODMISSING` error, in place of unnamed error (#6054). 2025-05-29 21:02:00 -04:00
Bartłomiej Chmiel 7dbe4f1807
Fix V3OrderParallel scoring contraction hang (#6052) 2025-05-29 10:31:57 -04:00
Todd Strader 5fcd0e52e7
Fix casting to arrays of enums (#6044) 2025-05-27 21:14:09 -04:00
Todd Strader 76aced4d40
Fix parameter types of user defined arrays (#6042) 2025-05-27 18:35:21 -04:00
Todd Strader 66259d8909
Fix GCC 10 read-only linker error (#6040) 2025-05-27 10:11:56 -04:00
Todd Strader 4b041c636f
Fix --x-initial and --x-assign random stability (#2662) (#5958) (#6018) (#6025) 2025-05-27 09:31:55 -04:00
Bartłomiej Chmiel 9cc4cc0efd
Add `--hierarchical-threads` (#6037) 2025-05-26 09:37:35 -04:00
Petr Nohavica 22d484d54d
Fix associative arrays with enum keys (#6034) (#6035) 2025-05-24 17:59:23 -04:00
Ryszard Rozak 90d4cf1361
Internals: V3Coverage cleanup. No functional change. (#6033) 2025-05-23 17:38:34 -04:00
Wilson Snyder 46c7b69c64 Internals: UINFO now includes newline itself. No functional change. 2025-05-22 20:29:32 -04:00
Wilson Snyder af30436357 Internals: Rename VL_PACK/VL_UNPACK in prep for future fix. No functional change intended. 2025-05-22 06:54:16 -04:00
Ryszard Rozak 2491f25da7
Add filtering type option in verilator_coverage (#6030) 2025-05-22 02:42:09 -07:00
Todd Strader d400584460
Fix concatenation and type casting (#6012) (#6013) 2025-05-21 08:41:29 -04:00
Wilson Snyder de08655c5b Internals: Fix some legacy casts. No functional change. 2025-05-20 22:51:54 -04:00
Bartłomiej Chmiel 6d257ef52c
Improve hierarchical scheduling visualization in V3ExecGraph (#6009) 2025-05-20 12:15:09 -04:00
Shou-Li Hsu 25cb31c38b
Add aggregate type error checks (#5570) (#5950) 2025-05-20 09:10:22 -04:00
Ryszard Rozak bed0456eca
Add ternary operator into branch coverage (#5880) 2025-05-19 09:35:35 -04:00
Wilson Snyder ad08302e5f Support parameter forward types. 2025-05-19 08:35:38 -04:00
Wilson Snyder 27eb8cfe8a Fix extraneous WIDTH warning on assoc.exists() 2025-05-18 11:25:25 -04:00
Yutetsu TAKATSUKASA b26658fd96
Fix wrong optimization result of shifted out variable (#6016) (#6019) 2025-05-18 07:18:37 -04:00
Wilson Snyder 0c8c7fb03c Remove symbol table from parser: Support redeclaring type as non-type; major parsing change (#2412). 2025-05-18 07:13:37 -04:00
Wilson Snyder 6bb16d6c52 Disable symbol from parser: Support redeclaring type as non-type; major parsing change (#2412). 2025-05-18 07:13:37 -04:00
Wilson Snyder 2c465d9741 Internals: Fix MSVC warning. 2025-05-17 22:56:59 -04:00
Wilson Snyder 3b632739a8 Internals: Add RequireDType and check for recursive data types, in prep for future parser. 2025-05-17 20:40:03 -04:00
Wilson Snyder 640339ec36 Revert 'Fix --x-initial and --x-assign random stability (#2662) (#5958).' See (#6018).
Reverts 4581023805 plus line in Changes file
2025-05-17 20:27:03 -04:00
Wilson Snyder 647404ec1e Tests: Improve warning coverage 2025-05-17 16:28:09 -04:00
Wilson Snyder 66667b6172
Support SARIF JSON diagnostic output with `--diagnostics-sarif`. (#6017) 2025-05-17 15:46:15 -04:00
Zhen Yan fc700538a5
Fix arithmetic left-shift by constants over 32 bits (#6007) (#6015) 2025-05-16 21:57:52 -04:00
github action 8d3b47a18a Apply 'make format' 2025-05-16 23:16:40 +00:00
Wilson Snyder 1bcd5ee0c1 Fix spelling 2025-05-16 19:02:19 -04:00
Todd Strader 4581023805
Fix --x-initial and --x-assign random stability (#2662) (#5958) 2025-05-16 13:54:51 -04:00
Ryszard Rozak 73b3648262
Fix skipped genblocks in toggle coverage (#6010)
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
Co-authored-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2025-05-16 08:24:57 -04:00
Zhen Yan 6b42d789af
Fix checking for too-wide divide and modulus (#6003) (#6006) 2025-05-15 10:43:45 -04:00
Ryszard Rozak 6db599da45
Fix slicing of AstExprStmt nodes (#6005) 2025-05-14 11:55:02 -04:00
Geza Lore 2f6ecd1853
Fix folding of LteS in DfgPeephole (#6004)
Fixes #6000
2025-05-14 13:33:20 +01:00
Wilson Snyder 4c4fdb5dfe Internals: Refactor some JSON and error code 2025-05-13 22:26:15 -04:00
Ryszard Rozak 91c52a4972
Support for assignments to concatenations with impure RHS (#6002) 2025-05-12 19:19:38 -04:00
Wilson Snyder ac2313ecb7 Fix some errors exceeding the --error-limit 2025-05-11 22:36:40 -04:00
Wilson Snyder fe4ad7de64 Internals: Use magic string for warnMore so lock-free. 2025-05-10 18:06:33 -04:00
Wilson Snyder 680236b03e Internals: Redo post-error additional information to be part of error calls. 2025-05-10 16:20:12 -04:00
Wilson Snyder 0f528d136d Fix arithmetic right-shift by constants over 32 bits (#5994). 2025-05-10 13:59:56 -04:00
Wilson Snyder d9dcde60a6 Fix duplicate error first-lines, and some internal V3Error cleanups 2025-05-10 13:29:30 -04:00
Yutetsu TAKATSUKASA 100e3d7702
Fix const-bit-op-tree with single-bit masks (#5993) (#5998) 2025-05-10 06:01:15 -04:00
Wilson Snyder d22608a49f Internals: Refactor common V3JsonFile. No functional change. 2025-05-09 22:00:29 -04:00
Wilson Snyder 5d0fd8b9a7 Commentary 2025-05-09 21:22:17 -04:00