verilator/test_regress/t/t_randstate_func.v

46 lines
893 B
Systemverilog
Raw Normal View History

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2023 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
class Cls;
2026-03-10 02:38:29 +01:00
rand int length;
2026-03-10 02:38:29 +01:00
function void test;
automatic int rand_result, v1, v2;
automatic string s;
2026-03-10 02:38:29 +01:00
// UVM 2023 does a print, so check is ascii
$display("get_randstate = '%s'", get_randstate());
2026-03-10 02:38:29 +01:00
s = get_randstate();
2026-03-10 02:38:29 +01:00
rand_result = randomize();
if (rand_result != 1) $stop;
v1 = length;
2026-03-10 02:38:29 +01:00
set_randstate(s);
2026-03-10 02:38:29 +01:00
rand_result = randomize();
if (rand_result != 1) $stop;
v2 = length;
`ifdef VERILATOR // About half of the other simulators fail at this
2026-03-10 02:38:29 +01:00
if (v1 != v2) $stop;
`endif
2026-03-10 02:38:29 +01:00
endfunction
endclass
module t;
2026-03-10 02:38:29 +01:00
initial begin
Cls c;
c = new;
c.test;
2026-03-10 02:38:29 +01:00
$write("*-* All Finished *-*\n");
$finish;
end
endmodule