Commit Graph

203 Commits

Author SHA1 Message Date
Yilou Wang 3ba9077726
Fix soft cross-object constraint priority inversion (#7228) (#7233)
Emit nested constraint setup tasks in depth-first order (deepest first)
so outer-scope soft constraints get higher priority per IEEE 18.5.13.
2026-03-10 19:02:15 -04:00
Rahul Behl 2046879beb
V3Randomize: Fix dist operator inside ConstraintIf blocks (#7221) (#7224)
The lowerDistConstraints() function was not recursing into ConstraintIf
nodes, causing dist operators inside if-else blocks to remain unlowered
and trigger an internal error when ConstraintExprVisitor encountered them.

Fix by adding recursive handling of ConstraintIf nodes in lowerDistConstraints:
- Check for AstConstraintIf nodes before AstConstraintExpr
- Recursively process thensp() and elsesp() branches
- This ensures all dist operators are lowered regardless of nesting

Test case: t_randomize_dist_conditional.v demonstrates conditional dist:
    constraint c {
      if (randd) {
        x dist { 8'd0 := 1, 8'd255 := 3 };  // 25% / 75%
      } else {
        x dist { 8'd0 := 3, 8'd255 := 1 };  // 75% / 25%
      }
    }

Fixes #7221
2026-03-10 07:06:00 +00:00
Rahul Behl efa53189ea
Support constraint `with` item.index array reduction (#7198) 2026-03-06 05:14:55 -05:00
Rahul Behl 9a5c1d27c8
Support array reduction methods with 'with' clause in constraints (#6455) (#6999) 2026-03-04 12:01:35 -05:00
Yilou Wang 3bc73cc768
Support constraint imperfect distributions (#6811) (#7168) 2026-03-03 11:23:14 -05:00
Yilou Wang ed84f3adb2
Support constraints on fixed-size array of class object members (#7170) (#7183) 2026-03-03 06:27:31 -05:00
Yilou Wang 8a413b3ec7
Fix std::randomize() in static function with static class members (#7167) (#7169) 2026-03-02 05:59:00 -05:00
Yilou Wang 108d209bd7
Support soft constraint solving with last-wins priority (#7124) (#7166) 2026-03-01 15:16:55 -05:00
Kamil Danecki df6b808c49
Fix parameters inside std::randomize `with` clause (#7140) 2026-02-28 09:53:05 -05:00
Geza Lore da51021b0a
Internals: Simplify AstForeach header handling (#7126)
Rename AstSelLoopVars to AstForeachHeader, and make it a non-NodeExpr.
Tweak parser to always create an AstForeachHeader, so no need to fix it
up later.
2026-02-22 18:57:12 +00:00
Yilou Wang 1717df0261
Support solve..before constraints (#5647) (#7123) 2026-02-22 11:33:18 -05:00
Geza Lore 579acced99
Internals: Make AstArg into an AstNode, not Expr (#7122) 2026-02-22 14:40:51 +00:00
Yilou Wang 443678d8c4
Support array reduction methods without 'with' clause in constraints for dynamic arrays (#7104) (#7108) 2026-02-22 09:23:02 -05:00
Geza Lore 78ee787bb1
Internals: Clean up AstArg usage in AstNodeFTaskRef (#7121)
- Strengthen type of AstNodeFTaskRef::pinsp to be List[AstArg]
- Rename 'pinsp' to 'argsp'
- Add default constructor arguments
2026-02-22 10:38:37 +00:00
Geza Lore e023113b79
Internals: Carry 'with' clause as op4 on AstNodeFTaskRef (#7114)
op4 is now available to carry the 'with' clause explicitly instead of
being part of the argument lit. Will strengthen 'pinsp' to be
List[AstArg] next.
2026-02-22 09:15:28 +00:00
Yilou Wang f25a85ea57
Fix associative array size() constraint generating invalid resize() call (#7103) (#7112) 2026-02-20 10:54:02 -05:00
Yilou Wang 0e26b049ea
Support function calls with random arguments in constraints (#7061) (#7083) 2026-02-19 15:37:55 +05:30
Ryszard Rozak 5d0352ab46
Fix conditional expressions in constraints (#7087) 2026-02-17 11:40:15 -05:00
Yilou Wang ed3aa43657
Fix enum variables in constraint solver producing invalid enum values (#7058) (#7065) 2026-02-16 22:44:38 -05:00
Yilou Wang 4357aee09a
Fix randomize() on null object handle crashing instead of returning 0 (#7059) (#7066) 2026-02-16 22:43:57 -05:00
Yilou Wang 994ef82e76
Support unique constraint on explicit array element subsets (#7057) (#7064) 2026-02-16 19:46:46 -05:00
Wilson Snyder 14a94b6de9 Internals: Add addNextNull. No functional change intended. 2026-02-16 08:09:29 -05:00
Kamil Danecki 821eacebea
Support power expressions with constant exponent in constraints (#7073) 2026-02-16 06:01:24 -05:00
Yilou Wang 9b1b9a5b3b
Fix randc cyclic behavior broken with constraints (#7029) (#7035) 2026-02-12 10:58:04 -05:00
Yilou Wang e41436bd4a
Support inherited and nested pre/post_randomize callbacks (#7049) (#7053) 2026-02-11 09:33:57 -08:00
Yilou Wang 554fcef627
Fix rand_mode()/constraint_mode() when used as function arguments (#7051) (#7055) 2026-02-11 09:33:09 -08:00
Yilou Wang 996a4b6e1a
Fix constraint_mode()/rand_mode() in constructor being overwritten by init code (#7054) 2026-02-11 09:32:08 -08:00
Yilou Wang 84350859e0
Support System Functions in Constraint Blocks (#7028) (#7036) 2026-02-11 05:19:25 -08:00
Pawel Kojma 5d12ae3a2f
Fix non-member identifiers used inside constraints (#7033) 2026-02-11 05:18:24 -08:00
Wilson Snyder 67bff893bf Fix whitespace 2026-02-10 20:17:22 -05:00
Yilou Wang 2bb807a931
Fix Inline foreach constraints on dynamic arrays of class objects (#7030) (#7037) 2026-02-10 15:22:31 -08:00
Yilou Wang 925543676e
Fix rand_mode() on nested object variables causes Z3 solver error (#7031) (#7034) 2026-02-10 13:59:09 -05:00
Yilou Wang 8791e6c5f2
Support constraint_mode() on static constraints (#7027) (#7038) 2026-02-10 13:58:35 -05:00
Igor Zaworski a660fa54a7
Fix unique constraint in derived class (#7022) 2026-02-09 09:56:38 -05:00
Geza Lore f0afcede10
Internals: Use pure expressions in V3Randomize (#6974) 2026-02-01 05:09:19 +00:00
Pawel Kojma 30e6cd9092
Fix accessing non-rand struct member in constraints (#6960) 2026-01-28 07:33:16 -05:00
Wilson Snyder 7c6c6a684b Add SPDX copyright identifiers, and get 'reuse' clean. No functional change. 2026-01-26 20:24:34 -05:00
Pawel Kojma c4dcdeab9a
Add parsing of solve-before inside foreach (#6934) 2026-01-20 07:14:11 -05:00
Wilson Snyder 50b6954cfc Internals: cppcheck cleanups 2026-01-17 23:18:09 -05:00
Srinivasan Venkataramanan 6fc9089a77
Support `unique` constraints (on 1D static arrays) (#6810) (#6878) 2026-01-16 08:42:09 -05:00
Yilou Wang 31f8be0b85
Support detailed failure info for constraint violations (#6617) (#6883)
* logging for the unsatisfied constraints

* Apply 'make format'

* fix teh quote error in the array indexing

* Apply 'make format'

* Len change for the hash for randomity when named assertion is used

* seperate name assertion and satisfied case

* Apply 'make format'

* simply comments and display info

* refine code and fix protect case

* format

* update display in test and .out file

* add an enable flag and warning type, add a protect_id version test and update out files

* Apply 'make format'

* simplify some comments

* update out file, ready to be merged.

* update .py file to set the hash key solid

* rename and reformate the warning message to follow the verilator style

* add a nowarn test

* Apply 'make format'

* ordering

---------

Co-authored-by: Udaya Raj Subedi <075bei047.udaya@pcampus.edu.np>
Co-authored-by: github action <action@example.com>
2026-01-12 15:53:49 +01:00
Ryszard Rozak 97d5844f2e
Support dynamic array elements in std::randomize (#6896) 2026-01-08 09:02:28 -05:00
Yilou Wang 6abfaf23a5
fix access flags in MemberSel randomization assignments (#6892) 2026-01-08 09:02:13 +01:00
Jakub Wasilewski 72a6da5ac8
Support complex expressions as std::randomize arguments (#6860) 2026-01-05 14:37:36 -05:00
Wilson Snyder 13327fa9c0 Copyright year update. 2026-01-01 07:22:09 -05:00
Wilson Snyder f6b966ed16 Fix `randc` on extended class (#6852). 2025-12-21 19:56:55 -05:00
Wilson Snyder ffa87540cc Fix randcase under fork (#6843). 2025-12-20 21:25:01 -05:00
Pawel Kojma 5244766b7b
Support reduction or in constraints (#6840) 2025-12-19 12:37:20 -05:00
Yilou Wang 41937ecbe4
Fix member select of variable without randmode (#6800) (#6833) 2025-12-18 06:49:04 -05:00
Yilou Wang f097e8a34e
Fix write variable placement for global constraints (#6740) (#6750) (#6797) 2025-12-11 14:16:34 -05:00