verilator/test_regress/t/t_constraint_state.v
Arkadiusz Kozdra 85356f464f
State-dependent constraints (#5217)
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2024-07-01 20:19:15 +02:00

37 lines
660 B
Systemverilog

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0
class Packet;
rand int rf;
int state;
constraint c { rf == state; }
endclass
module t (/*AUTOARG*/);
Packet p;
int v;
initial begin
p = new;
p.state = 123;
v = p.randomize();
if (v != 1) $stop;
if (p.rf != 123) $stop;
p.state = 234;
v = p.randomize();
if (v != 1) $stop;
if (p.rf != 234) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule