Skip to content

Commit

Permalink
Add regression test for logic class property default value
Browse files Browse the repository at this point in the history
Check that class logic class properties get initialized to 'x.

Signed-off-by: Lars-Peter Clausen <[email protected]>
  • Loading branch information
larsclausen committed Jan 5, 2025
1 parent 4854de0 commit c22b375
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ivtest/ivltests/sv_class_prop_logic.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Check that logic class properties are initialized to 'x.

module test;

bit failed = 1'b0;

`define check(val, exp) do \
if (val != exp) begin \
$display("FAILED(%0d). '%s' expected %d, got %d", `__LINE__, `"val`", exp, val); \
failed = 1'b1; \
end \
while(0)

class C;
logic [31:0] x;
endclass

C c;

initial begin
c = new;
`check(c.x, 32'hxx);

if (!failed) begin
$display("PASSED");
end
end
endmodule
1 change: 1 addition & 0 deletions ivtest/regress-vvp.list
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json
sv_chained_constructor3 vvp_tests/sv_chained_constructor3.json
sv_chained_constructor4 vvp_tests/sv_chained_constructor4.json
sv_chained_constructor5 vvp_tests/sv_chained_constructor5.json
sv_class_prop_logic vvp_tests/sv_class_prop_logic.json
sv_const1 vvp_tests/sv_const1.json
sv_const2 vvp_tests/sv_const2.json
sv_const3 vvp_tests/sv_const3.json
Expand Down
5 changes: 5 additions & 0 deletions ivtest/vvp_tests/sv_class_prop_logic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "sv_class_prop_logic.v",
"iverilog-args" : [ "-g2005-sv" ]
}

0 comments on commit c22b375

Please sign in to comment.