From b883f7713c7b754840d87184b32df2f5f441681f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 6 Aug 2026 22:25:16 -0700 Subject: [PATCH] Add regression test for nested const property initialization Check that a const property can be assigned from a named block inside its class constructor. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_const_nested_block.v | 27 +++++++++++++++++++ ivtest/regress-vvp.list | 1 + .../sv_class_const_nested_block.json | 9 +++++++ 3 files changed, 37 insertions(+) create mode 100644 ivtest/ivltests/sv_class_const_nested_block.v create mode 100644 ivtest/vvp_tests/sv_class_const_nested_block.json diff --git a/ivtest/ivltests/sv_class_const_nested_block.v b/ivtest/ivltests/sv_class_const_nested_block.v new file mode 100644 index 000000000..3c3fabd94 --- /dev/null +++ b/ivtest/ivltests/sv_class_const_nested_block.v @@ -0,0 +1,27 @@ +// Check const property initialization in a nested constructor block. + +module test; + + class C; + const int value; + + function new; + begin : initialize + value = 42; + end + endfunction + endclass + + C object; + + initial begin + object = new; + + if (object.value !== 42) begin + $display("FAILED: expected 42, got %0d", object.value); + end else begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 9d338fd9b..a992aea2f 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -286,6 +286,7 @@ 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_const_derived vvp_tests/sv_class_const_derived.json +sv_class_const_nested_block vvp_tests/sv_class_const_nested_block.json sv_class_nested_method_call vvp_tests/sv_class_nested_method_call.json sv_class_prop_assign_op1 vvp_tests/sv_class_prop_assign_op1.json sv_class_prop_assign_op2 vvp_tests/sv_class_prop_assign_op2.json diff --git a/ivtest/vvp_tests/sv_class_const_nested_block.json b/ivtest/vvp_tests/sv_class_const_nested_block.json new file mode 100644 index 000000000..8426ef661 --- /dev/null +++ b/ivtest/vvp_tests/sv_class_const_nested_block.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "sv_class_const_nested_block.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Classes are not supported", + "type" : "CE" + } +}