Skip to content

Commit

Permalink
Add test with randomize with
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak committed Nov 29, 2024
1 parent f1df872 commit 2b3b370
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test_regress/t/t_rand_with_queue_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0

import vltest_bootstrap

test.scenarios('simulator')

if not test.have_solver:
test.skip("No constraint solver installed")

test.compile()

test.execute()

test.passes()
31 changes: 31 additions & 0 deletions test_regress/t/t_rand_with_queue_size.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2024 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0

class Foo;
rand int q[$];
rand int q2[$][$];
rand int r;
int x = 1;
constraint c {
q.size() == 15;
q2.size() == 10;
}
endclass

module t;
initial begin
Foo foo = new;

int res = foo.randomize() with {r < 5;};
if (res != 1) $stop;
if (foo.q.size() != 15) $stop;
if (foo.q2.size() != 10) $stop;
if (foo.r >= 5) $stop;

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

0 comments on commit 2b3b370

Please sign in to comment.