Files
iverilog/ivtest/ivltests/sv_class_method_var_init.v
T
Lars-Peter Clausen da4ac3607a Add regression test for var init in class method
Check that variable initialization as part of the declaration works as
expected in class methods.

Signed-off-by: Lars-Peter Clausen <[email protected]>
2022-12-21 19:28:46 -08:00

26 lines
503 B
Verilog

// Check that variable initialization as part of the declaration works as
// expected in class methods.
module test;
class C;
task t(bit check);
int x = 10; // The initialization should happen on each invocation
if (check) begin
if (x === 10) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
x = 20;
endtask
endclass
initial begin
C c;
c = new;
c.t(1'b0);
c.t(1'b1);
end
endmodule