diff --git a/ivtest/ivltests/sv_class_prop_assign_op1.v b/ivtest/ivltests/sv_class_prop_assign_op1.v new file mode 100644 index 000000000..7d000d7fd --- /dev/null +++ b/ivtest/ivltests/sv_class_prop_assign_op1.v @@ -0,0 +1,58 @@ +// Check that assignment operators are supported on class properties. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + class C; + integer x; + endclass + + integer i; + C c; + + initial begin + c = new; + + c.x = 1; + c.x += 5; + `check(c.x, 6); + c.x -= 2; + `check(c.x, 4); + c.x *= 25; + `check(c.x, 100); + c.x /= 5; + `check(c.x, 20); + c.x %= 3; + `check(c.x, 2); + + c.x = 'haa; + c.x &= 'h33; + `check(c.x, 'h22); + c.x |= 'h11; + `check(c.x, 'h33); + c.x ^= 'h22; + `check(c.x, 'h11); + + c.x <<= 3; + `check(c.x, 'h88); + c.x <<<= 1; + `check(c.x, 'h110); + c.x >>= 2; + `check(c.x, 'h44); + c.x >>>= 1; + `check(c.x, 'h22); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_class_prop_assign_op2.v b/ivtest/ivltests/sv_class_prop_assign_op2.v new file mode 100644 index 000000000..a590c45f0 --- /dev/null +++ b/ivtest/ivltests/sv_class_prop_assign_op2.v @@ -0,0 +1,58 @@ +// Check that assignment operators are supported on static class properties. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + class C; + static integer x; + endclass + + integer i; + C c; + + initial begin + c = new; + + c.x = 1; + c.x += 5; + `check(c.x, 6); + c.x -= 2; + `check(c.x, 4); + c.x *= 25; + `check(c.x, 100); + c.x /= 5; + `check(c.x, 20); + c.x %= 3; + `check(c.x, 2); + + c.x = 'haa; + c.x &= 'h33; + `check(c.x, 'h22); + c.x |= 'h11; + `check(c.x, 'h33); + c.x ^= 'h22; + `check(c.x, 'h11); + + c.x <<= 3; + `check(c.x, 'h88); + c.x <<<= 1; + `check(c.x, 'h110); + c.x >>= 2; + `check(c.x, 'h44); + c.x >>>= 1; + `check(c.x, 'h22); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 6c05287de..07e2b64a8 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -222,6 +222,8 @@ 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_assign_op1 vvp_tests/sv_class_prop_assign_op1.json +sv_class_prop_assign_op2 vvp_tests/sv_class_prop_assign_op2.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 diff --git a/ivtest/vvp_tests/sv_class_prop_assign_op1.json b/ivtest/vvp_tests/sv_class_prop_assign_op1.json new file mode 100644 index 000000000..ce63aecf4 --- /dev/null +++ b/ivtest/vvp_tests/sv_class_prop_assign_op1.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_class_prop_assign_op1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_class_prop_assign_op2.json b/ivtest/vvp_tests/sv_class_prop_assign_op2.json new file mode 100644 index 000000000..9079785f9 --- /dev/null +++ b/ivtest/vvp_tests/sv_class_prop_assign_op2.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_class_prop_assign_op2.v", + "iverilog-args" : [ "-g2005-sv" ] +}