diff --git a/ivtest/ivltests/enum_compatibility4.v b/ivtest/ivltests/enum_compatibility4.v new file mode 100644 index 000000000..0bb059c4b --- /dev/null +++ b/ivtest/ivltests/enum_compatibility4.v @@ -0,0 +1,23 @@ +// Check that assigning to a enum types variable from an enum typed class +// array element works. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + E e; + E ea[2]; + + initial begin + ea[0] = B; + e = ea[0]; + if (e === B) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility5.v b/ivtest/ivltests/enum_compatibility5.v new file mode 100644 index 000000000..29287c7cd --- /dev/null +++ b/ivtest/ivltests/enum_compatibility5.v @@ -0,0 +1,25 @@ +// Check that assigning to a enum types variable from an enum typed function +// call works. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + function E f(); + return B; + endfunction + + E e; + + initial begin + e = f(); + if (e === B) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility6.v b/ivtest/ivltests/enum_compatibility6.v new file mode 100644 index 000000000..72a4c1181 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility6.v @@ -0,0 +1,21 @@ +// Check that passing an enum type task argument works. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + task t(E e); + if (e === B) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + endtask + + initial begin + t(B); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility7.v b/ivtest/ivltests/enum_compatibility7.v new file mode 100644 index 000000000..875dcb9ee --- /dev/null +++ b/ivtest/ivltests/enum_compatibility7.v @@ -0,0 +1,26 @@ +// Check that assigning to a enum types variable from an enum typed struct +// member works. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + struct packed { + E e; + } s; + + E e; + + initial begin + s.e = B; + e = s.e; + if (e === B) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility8.v b/ivtest/ivltests/enum_compatibility8.v new file mode 100644 index 000000000..94421437f --- /dev/null +++ b/ivtest/ivltests/enum_compatibility8.v @@ -0,0 +1,28 @@ +// Check that assigning to a enum types variable from an enum typed class +// property works. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + class C; + E e; + endclass + + C c; + E e; + + initial begin + c = new; + c.e = B; + e = c.e; + if (e === B) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail.v b/ivtest/ivltests/enum_compatibility_fail1.v similarity index 100% rename from ivtest/ivltests/enum_compatibility_fail.v rename to ivtest/ivltests/enum_compatibility_fail1.v diff --git a/ivtest/ivltests/enum_compatibility_fail2.v b/ivtest/ivltests/enum_compatibility_fail2.v new file mode 100644 index 000000000..c1f9cba93 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail2.v @@ -0,0 +1,17 @@ +// Check that an error is reported for implicit cast to enum when assigning +// to an array element. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + E ea[2]; + + initial begin + ea[0] = 10; // This should fail. Implicit cast to enum. + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail3.v b/ivtest/ivltests/enum_compatibility_fail3.v new file mode 100644 index 000000000..f005e1afb --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail3.v @@ -0,0 +1,19 @@ +// Check that an error is reported for implicit cast to enum when assigning +// from an array element. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + E e; + int ea[2]; + + initial begin + ea[0] = B; // This is OK. + e = ea[0]; // This should fail. Implicit cast to enum. + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail4.v b/ivtest/ivltests/enum_compatibility_fail4.v new file mode 100644 index 000000000..341b6b3d0 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail4.v @@ -0,0 +1,21 @@ +// Check that an error is reported for implicit cast to enum when assigning +// from a function call. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + function integer f(); + return B; + endfunction + + E e; + + initial begin + e = f(); // This should fail. Implicit cast to enum type. + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail5.v b/ivtest/ivltests/enum_compatibility_fail5.v new file mode 100644 index 000000000..e12bed9f2 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail5.v @@ -0,0 +1,17 @@ +// Check that an error is reported for implicit cast to enum for task arguments. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + task t(E e); + $display("FAILED"); + endtask + + initial begin + t(10); // This should fail. Implicit cast to enum. + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail6.v b/ivtest/ivltests/enum_compatibility_fail6.v new file mode 100644 index 000000000..1619b9f63 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail6.v @@ -0,0 +1,19 @@ +// Check that an error is reported for implicit cast to enum when assigning to +// struct members. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + struct packed { + E e; + } s; + + initial begin + s.e = 10; // This should fail. Implicit cast to enum. + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail7.v b/ivtest/ivltests/enum_compatibility_fail7.v new file mode 100644 index 000000000..d456bb7a2 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail7.v @@ -0,0 +1,22 @@ +// Check that an error is reported for implicit cast to enum when assigning to +// class properties. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + class C; + E e; + endclass + + C c; + + initial begin + c = new; + c.e = 10; // This should fail. Implicit cast to enum. + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/enum_compatibility_fail8.v b/ivtest/ivltests/enum_compatibility_fail8.v new file mode 100644 index 000000000..e487af825 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail8.v @@ -0,0 +1,21 @@ +// Check that an error is reported for implicit cast to enum in function return +// statements. + +module test; + + typedef enum reg [31:0] { + A, B + } E; + + function E f(); + return 10; // This should fail. Implicit cast to enum. + endfunction + + E e; + + initial begin + e = f(); + $display("FAILED"); + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 18d0d6f0c..ccd5342f2 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -278,7 +278,19 @@ enum_base_typename2 normal,-g2005-sv ivltests enum_compatibility1 normal,-g2005-sv ivltests enum_compatibility2 normal,-g2005-sv ivltests enum_compatibility3 normal,-g2005-sv ivltests -enum_compatibility_fail CE,-g2005-sv ivltests +enum_compatibility4 normal,-g2005-sv ivltests +enum_compatibility5 normal,-g2005-sv ivltests +enum_compatibility6 normal,-g2005-sv ivltests +enum_compatibility7 normal,-g2005-sv ivltests +enum_compatibility8 normal,-g2005-sv ivltests +enum_compatibility_fail1 CE,-g2005-sv ivltests +enum_compatibility_fail2 CE,-g2005-sv ivltests +enum_compatibility_fail3 CE,-g2005-sv ivltests +enum_compatibility_fail4 CE,-g2005-sv ivltests +enum_compatibility_fail5 CE,-g2005-sv ivltests +enum_compatibility_fail6 CE,-g2005-sv ivltests +enum_compatibility_fail7 CE,-g2005-sv ivltests +enum_compatibility_fail8 CE,-g2005-sv ivltests enum_elem_ranges normal,-g2005-sv ivltests enum_dims_invalid CE,-g2005-sv ivltests enum_in_struct normal,-g2005-sv ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index f26123ae1..9906e5dc0 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -389,6 +389,7 @@ br_gh391 CE,-g2009 ivltests br_gh437 CE,-g2009 ivltests br_gh445 CE,-g2009 ivltests br_gh461 CE,-g2009 ivltests +enum_compatibility8 CE,-g2005-sv ivltests enum_in_class CE,-g2005-sv ivltests enum_in_class_name_coll CE,-g2005-sv ivltests sv_class1 CE,-g2009 ivltests