From 4ef5b02bcd647c48f54444ac25419c4b270845d4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 15 Oct 2022 15:40:09 +0200 Subject: [PATCH] Add regression tests for continuous array assign compatibility Check various different scenarios for array compatibility in continuous array assign. Both testing cases that should work and cases that should fail. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_array_cassign1.v | 14 ++++++++++++++ ivtest/ivltests/sv_array_cassign2.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign3.v | 15 +++++++++++++++ ivtest/ivltests/sv_array_cassign4.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign5.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail1.v | 15 +++++++++++++++ ivtest/ivltests/sv_array_cassign_fail10.v | 18 ++++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail11.v | 18 ++++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail2.v | 15 +++++++++++++++ ivtest/ivltests/sv_array_cassign_fail3.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail4.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail5.v | 16 ++++++++++++++++ ivtest/ivltests/sv_array_cassign_fail6.v | 14 ++++++++++++++ ivtest/ivltests/sv_array_cassign_fail7.v | 15 +++++++++++++++ ivtest/ivltests/sv_array_cassign_fail8.v | 15 +++++++++++++++ ivtest/ivltests/sv_array_cassign_fail9.v | 15 +++++++++++++++ ivtest/regress-sv.list | 16 ++++++++++++++++ ivtest/regress-vlog95.list | 5 +++++ 18 files changed, 271 insertions(+) create mode 100644 ivtest/ivltests/sv_array_cassign1.v create mode 100644 ivtest/ivltests/sv_array_cassign2.v create mode 100644 ivtest/ivltests/sv_array_cassign3.v create mode 100644 ivtest/ivltests/sv_array_cassign4.v create mode 100644 ivtest/ivltests/sv_array_cassign5.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail1.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail10.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail11.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail2.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail3.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail4.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail5.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail6.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail7.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail8.v create mode 100644 ivtest/ivltests/sv_array_cassign_fail9.v diff --git a/ivtest/ivltests/sv_array_cassign1.v b/ivtest/ivltests/sv_array_cassign1.v new file mode 100644 index 000000000..66c5cec4d --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign1.v @@ -0,0 +1,14 @@ +// Check that continuous assignment of two compatible arrays is supported + +module test; + + wire [1:0] x[1:0]; + wire [1:0] y[1:0]; + + assign x = y; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign2.v b/ivtest/ivltests/sv_array_cassign2.v new file mode 100644 index 000000000..cbf851e27 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign2.v @@ -0,0 +1,16 @@ +// Check that continuous assignment of two compatible arrays is supported, even +// if the upper and lower bounds of the arrays are not identical, as long as the +// size is the same. + +module test; + + wire [1:0] x[1:0]; + wire [1:0] y[2:1]; + + assign x = y; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign3.v b/ivtest/ivltests/sv_array_cassign3.v new file mode 100644 index 000000000..f89025ab3 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign3.v @@ -0,0 +1,15 @@ +// Check that continuous assignment of two compatible arrays is supported, even +// if the element types are not identical, but just equivalent. + +module test; + + wire [1:0] x[1:0]; + wire [2:1] y[1:0]; + + assign x = y; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign4.v b/ivtest/ivltests/sv_array_cassign4.v new file mode 100644 index 000000000..4caf6c31e --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign4.v @@ -0,0 +1,16 @@ +// Check that continuous assignment of two compatible arrays is supported, even +// if the element types are not identical and one is a built-in integer and the +// other a equivalent packed type. + +module test; + + wire signed [31:0] x[1:0]; + wire integer y[1:0]; + + assign x = y; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign5.v b/ivtest/ivltests/sv_array_cassign5.v new file mode 100644 index 000000000..b4bf1a98b --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign5.v @@ -0,0 +1,16 @@ +// Check that continuous assignment of two compatible arrays is supported, even +// if the element types have different number of dimensions, but have the same +// packed width. + +module test; + + wire [3:0] x[1:0]; + wire [1:0][1:0] y[1:0]; + + assign x = y; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail1.v b/ivtest/ivltests/sv_array_cassign_fail1.v new file mode 100644 index 000000000..c07dcc896 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail1.v @@ -0,0 +1,15 @@ +// Check that it is an error if the element type is not the same in a +// continuous array assignment. + +module test; + + wire [3:0] x[1:0]; + reg [1:0] y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail10.v b/ivtest/ivltests/sv_array_cassign_fail10.v new file mode 100644 index 000000000..0a72c11c2 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail10.v @@ -0,0 +1,18 @@ +// Check that it is an error trying to continuously assign an unpacked array +// with an enum element type to another unpacked array with an element type that +// is not the same enum type, even if the two element types are the same size. + +module test; + + wire integer x[1:0]; + enum integer { + A + } y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail11.v b/ivtest/ivltests/sv_array_cassign_fail11.v new file mode 100644 index 000000000..12e11384c --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail11.v @@ -0,0 +1,18 @@ +// Check that it is an error to continuously assign an unpacked array with an +// enum element type if the other unpacked array element type is not the same +// enum type, even if the two element types are the same size. + +module test; + + wire enum integer { + A + } x[1:0]; + integer y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail2.v b/ivtest/ivltests/sv_array_cassign_fail2.v new file mode 100644 index 000000000..971ec2bb6 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail2.v @@ -0,0 +1,15 @@ +// Check that it is an error if the array size is not the same in a continuous +// unpacked array assignment. + +module test; + + wire [1:0] x[2:0]; + reg [1:0] y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail3.v b/ivtest/ivltests/sv_array_cassign_fail3.v new file mode 100644 index 000000000..3478b84c8 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail3.v @@ -0,0 +1,16 @@ +// Check that it is an error if the number of unpacked dimensions do not match +// in an continuous array assignment, even if the canonical size of the array is +// the same. + +module test; + + wire [1:0] x[1:0][1:0]; + reg [1:0] y[3:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail4.v b/ivtest/ivltests/sv_array_cassign_fail4.v new file mode 100644 index 000000000..91ad48202 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail4.v @@ -0,0 +1,16 @@ +// Check that it is an error if the element type is not the same in a +// continuous array assignment, even if the difference is just 2-state vs. +// 4-state. + +module test; + + wire [1:0] x[1:0]; + bit [1:0] y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail5.v b/ivtest/ivltests/sv_array_cassign_fail5.v new file mode 100644 index 000000000..4801f9ca7 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail5.v @@ -0,0 +1,16 @@ +// Check that it is an error if the element type is not the same in a +// continuous array assignment, even if one of the types is a packed type and +// the other is a real type. + +module test; + + wire [1:0] x[1:0]; + real [1:0] y[1:0]; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail6.v b/ivtest/ivltests/sv_array_cassign_fail6.v new file mode 100644 index 000000000..fc5063be9 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail6.v @@ -0,0 +1,14 @@ +// Check that it is an error trying to continuously assign a scalar expression +// to a unpacked array. + +module test; + + wire [1:0] x[1:0]; + + assign x = 1'b1 + 1'b1; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail7.v b/ivtest/ivltests/sv_array_cassign_fail7.v new file mode 100644 index 000000000..a534e845e --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail7.v @@ -0,0 +1,15 @@ +// Check that it is an error trying to continuously assign a scalar variable to +// an unpacked array. + +module test; + + wire [1:0] x[1:0]; + reg [1:0] y; + + assign x = y; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail8.v b/ivtest/ivltests/sv_array_cassign_fail8.v new file mode 100644 index 000000000..762ba4074 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail8.v @@ -0,0 +1,15 @@ +// Check that it is an error trying to continuously assign a scalar net to an +// unpacked array. + +module test; + + wire a[1:0]; + wire x; + + assign a = x; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_array_cassign_fail9.v b/ivtest/ivltests/sv_array_cassign_fail9.v new file mode 100644 index 000000000..b685200b1 --- /dev/null +++ b/ivtest/ivltests/sv_array_cassign_fail9.v @@ -0,0 +1,15 @@ +// Check that it is an error trying to continuously assign an element of an +// unpacked array to another unpacked array as a whole. + +module test; + + wire a[1:0]; + wire x[1:0]; + + assign a = x[0]; + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index d002e84a3..52f592c44 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -500,6 +500,22 @@ sv_assign_pattern_func normal,-g2005-sv ivltests sv_assign_pattern_op normal,-g2005-sv ivltests sv_assign_pattern_part normal,-g2005-sv ivltests sv_array_assign_pattern2 normal,-g2009 ivltests +sv_array_cassign1 normal,-g2005-sv ivltests +sv_array_cassign2 normal,-g2005-sv ivltests +sv_array_cassign3 normal,-g2005-sv ivltests +sv_array_cassign4 normal,-g2005-sv ivltests +sv_array_cassign5 normal,-g2005-sv ivltests +sv_array_cassign_fail1 CE,-g2005-sv ivltests +sv_array_cassign_fail2 CE,-g2005-sv ivltests +sv_array_cassign_fail3 CE,-g2005-sv ivltests +sv_array_cassign_fail4 CE,-g2005-sv ivltests +sv_array_cassign_fail5 CE,-g2005-sv ivltests +sv_array_cassign_fail6 CE,-g2005-sv ivltests +sv_array_cassign_fail7 CE,-g2005-sv ivltests +sv_array_cassign_fail8 CE,-g2005-sv ivltests +sv_array_cassign_fail9 CE,-g2005-sv ivltests +sv_array_cassign_fail10 CE,-g2005-sv ivltests +sv_array_cassign_fail11 CE,-g2005-sv ivltests sv_array_query normal,-g2005-sv ivltests sv_cast_integer normal,-g2005-sv ivltests sv_cast_integer2 normal,-g2005-sv ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index acd4b9f86..ed42175a3 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -257,6 +257,11 @@ scan-invalid CE ivltests sel_rval_bit_ob CE ivltests sel_rval_part_ob CE ivltests signed_net_display CE,-pallowsigned=1 ivltests +sv_array_cassign1 CE,-g2005-sv ivltests +sv_array_cassign2 CE,-g2005-sv ivltests +sv_array_cassign3 CE,-g2005-sv ivltests +sv_array_cassign4 CE,-g2005-sv ivltests +sv_array_cassign5 CE,-g2005-sv ivltests sv_unpacked_port CE,-g2009 ivltests sv_unpacked_port2 CE,-g2009,-pallowsigned=1 ivltests sv_unpacked_wire CE,-g2009 ivltests