From b7a92160bd80e07083bb18c57f4651075d8d2386 Mon Sep 17 00:00:00 2001 From: Yilou Wang Date: Thu, 9 Jul 2026 09:23:09 +0200 Subject: [PATCH] Cover member-select rand_mode gate for sub-object frozen array --- .../t/t_randomize_scoped_arg_array_randmode.v | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test_regress/t/t_randomize_scoped_arg_array_randmode.v b/test_regress/t/t_randomize_scoped_arg_array_randmode.v index 20cf7b879..feb3d5095 100644 --- a/test_regress/t/t_randomize_scoped_arg_array_randmode.v +++ b/test_regress/t/t_randomize_scoped_arg_array_randmode.v @@ -74,6 +74,21 @@ class AssocInt extends Base; endfunction endclass +class Leaf; + rand uint a[3]; + constraint c {foreach (a[i]) a[i] inside {[1:10]};} +endclass + +class Nested; + rand uint x; + rand Leaf leaf; + constraint xc {x inside {[1:100]};} + constraint lc {foreach (leaf.a[i]) leaf.a[i] inside {[1:10]};} + function new(); + leaf = new; + endfunction +endclass + class NoModes; // no rand_mode() call anywhere; scoped arg only rand uint x, y; rand uint arr[2]; @@ -212,6 +227,23 @@ module t; end end + // Frozen rand array inside a sub-object: mode gate via member select. + begin + Nested n; + uint snapn[3]; + n = new; + ok = n.randomize(); + `checkd(ok, 1); + n.leaf.a.rand_mode(0); + snapn = n.leaf.a; + for (int i = 0; i < 5; ++i) begin + ok = n.randomize(); + `checkd(ok, 1); + if (n.leaf.a !== snapn) `checkd(0, 1); + if (n.x < 1 || n.x > 100) `checkd(0, 1); + end + end + $write("*-* All Finished *-*\n"); $finish; end