Skip to content

Commit

Permalink
Add test that checks if class objects are retained
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak committed Nov 6, 2024
1 parent da4893a commit b2b0be3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test_regress/t/t_randomize_queue_size.v
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ end

class Foo;
rand int q[$];
int x = 1;
constraint c {
q.size() == 15;
}
Expand All @@ -43,16 +44,38 @@ class Bar;
}
endclass

class Baz;
rand Foo foo_arr[];
constraint c_foo {
foo_arr.size == 7;
}
endclass

module t;
initial begin
Foo foo = new;
Bar bar = new;
Baz baz = new;

void'(foo.randomize());
if (foo.q.size() != 15) $stop;

`check_rand(bar, bar.q.size(), bar.q.size() > 2 && bar.q.size() < 10);
`check_rand(bar, bar.q2.size(), bar.q2.size() < 7);

baz.foo_arr = new[4];
for (int i = 0; i < 4; i++) baz.foo_arr[i] = new;
baz.foo_arr[2].x = 2;
void'(baz.randomize());

if (baz.foo_arr.size() != 7) $stop;
for (int i = 0; i < 4; i++)
if (baz.foo_arr[i] == null) $stop;
for (int i = 4; i < 7; i++)
if (baz.foo_arr[i] != null) $stop;
if (baz.foo_arr[2].x != 2) $stop;
`check_rand(baz, baz.foo_arr[1].q[5], 1'b1);

$write("*-* All Finished *-*\n");
$finish;
end
Expand Down

0 comments on commit b2b0be3

Please sign in to comment.