Tests: Add t_rand_stability_class

This commit is contained in:
Wilson Snyder 2025-12-21 15:28:10 -05:00
parent c0a0f0dab9
commit a6f608c616
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 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')
test.compile()
test.execute()
test.passes()

View File

@ -0,0 +1,33 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t;
class Cls;
task test_srandom;
int i, j, k;
// $urandom is per-process thread, not affected by object stability/this.srandom(seed)
// "Each object maintains its own internal RNG, which is used exclusively by its randomize() method."
// THis was moved to t_rand_stability_class.v
this.srandom(1234);
i = $urandom;
this.srandom(1234);
j = $urandom;
this.srandom(1234);
k = $urandom;
if (i == j && i == k) $stop; // Small chance randomly i == j, or j == k
endtask
endclass
Cls c1;
initial begin
c1 = new;
c1.test_srandom;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule