From ee81ac2f8517468b56614bc2d520c6d297637939 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Mar 2022 10:21:02 +0100 Subject: [PATCH] Add regression tests for module non-ANSI port declarations Check that it is possible to define the data type of a non-ANSI module port in a separate declaration from the port direction. Add tests for both the type declared before the port direction and for the type declared after the port direction. Note that this doesn't work yet correctly for integer type module ports yet, so there are no tests for this. This will be addressed in follow up work. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/module_nonansi_enum1.v | 21 +++++++++++++++++++++ ivtest/ivltests/module_nonansi_enum2.v | 20 ++++++++++++++++++++ ivtest/ivltests/module_nonansi_parray1.v | 20 ++++++++++++++++++++ ivtest/ivltests/module_nonansi_parray2.v | 19 +++++++++++++++++++ ivtest/ivltests/module_nonansi_real1.v | 17 +++++++++++++++++ ivtest/ivltests/module_nonansi_real2.v | 16 ++++++++++++++++ ivtest/ivltests/module_nonansi_struct1.v | 22 ++++++++++++++++++++++ ivtest/ivltests/module_nonansi_struct2.v | 21 +++++++++++++++++++++ ivtest/ivltests/module_nonansi_vec1.v | 17 +++++++++++++++++ ivtest/ivltests/module_nonansi_vec2.v | 16 ++++++++++++++++ ivtest/regress-sv.list | 8 ++++++++ ivtest/regress-vlg.list | 2 ++ 12 files changed, 199 insertions(+) create mode 100644 ivtest/ivltests/module_nonansi_enum1.v create mode 100644 ivtest/ivltests/module_nonansi_enum2.v create mode 100644 ivtest/ivltests/module_nonansi_parray1.v create mode 100644 ivtest/ivltests/module_nonansi_parray2.v create mode 100644 ivtest/ivltests/module_nonansi_real1.v create mode 100644 ivtest/ivltests/module_nonansi_real2.v create mode 100644 ivtest/ivltests/module_nonansi_struct1.v create mode 100644 ivtest/ivltests/module_nonansi_struct2.v create mode 100644 ivtest/ivltests/module_nonansi_vec1.v create mode 100644 ivtest/ivltests/module_nonansi_vec2.v diff --git a/ivtest/ivltests/module_nonansi_enum1.v b/ivtest/ivltests/module_nonansi_enum1.v new file mode 100644 index 000000000..d418f8762 --- /dev/null +++ b/ivtest/ivltests/module_nonansi_enum1.v @@ -0,0 +1,21 @@ +// Check that it is possible to declare the data type for a enum type module +// port separately from the direction for non-ANSI style port declarations. +// declarations. + +typedef enum integer { + A, B +} T; + +module test(x); + output x; + T x; + + initial begin + if ($bits(x) == $bits(T)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_enum2.v b/ivtest/ivltests/module_nonansi_enum2.v new file mode 100644 index 000000000..f64a588ea --- /dev/null +++ b/ivtest/ivltests/module_nonansi_enum2.v @@ -0,0 +1,20 @@ +// Check that it is possible to declare the data type for a enum type module +// port before the direction for non-ANSI style port declarations. + +typedef enum integer { + A, B +} T; + +module test(x); + T x; + output x; + + initial begin + if ($bits(x) == $bits(T)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_parray1.v b/ivtest/ivltests/module_nonansi_parray1.v new file mode 100644 index 000000000..722e13c16 --- /dev/null +++ b/ivtest/ivltests/module_nonansi_parray1.v @@ -0,0 +1,20 @@ +// Check that it is possible to declare the data type for a packed array module +// port separately from the direction for non-ANSI style port declarations. +// declarations. + +typedef logic [3:0] T1; +typedef T1 [7:0] T2; + +module test(x); + output x; + T2 x; + + initial begin + if ($bits(x) == $bits(T2)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_parray2.v b/ivtest/ivltests/module_nonansi_parray2.v new file mode 100644 index 000000000..cecac9859 --- /dev/null +++ b/ivtest/ivltests/module_nonansi_parray2.v @@ -0,0 +1,19 @@ +// Check that it is possible to declare the data type for a packed array module +// port before the direction for non-ANSI style port declarations. + +typedef logic [3:0] T1; +typedef T1 [7:0] T2; + +module test(x); + T2 x; + output x; + + initial begin + if ($bits(x) == $bits(T2)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_real1.v b/ivtest/ivltests/module_nonansi_real1.v new file mode 100644 index 000000000..743ddde1a --- /dev/null +++ b/ivtest/ivltests/module_nonansi_real1.v @@ -0,0 +1,17 @@ +// Check that it is possible to declare the data type for a real type module +// port separately from the direction for non-ANSI style port declarations. +// declarations. + +module test(x); + output x; + real x; + + initial begin + if (x == 0.0) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_real2.v b/ivtest/ivltests/module_nonansi_real2.v new file mode 100644 index 000000000..880b07693 --- /dev/null +++ b/ivtest/ivltests/module_nonansi_real2.v @@ -0,0 +1,16 @@ +// Check that it is possible to declare the data type for a real type module +// port before the direction for non-ANSI style port declarations. + +module test(x); + real x; + output x; + + initial begin + if (x == 0.0) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_struct1.v b/ivtest/ivltests/module_nonansi_struct1.v new file mode 100644 index 000000000..1fdf43b8d --- /dev/null +++ b/ivtest/ivltests/module_nonansi_struct1.v @@ -0,0 +1,22 @@ +// Check that it is possible to declare the data type for a struct type module +// port separately from the direction for non-ANSI style port declarations. +// declarations. + +typedef struct packed { + reg [31:0] x; + reg [7:0] y; +} T; + +module test(x); + output x; + T x; + + initial begin + if ($bits(x) == $bits(T)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_struct2.v b/ivtest/ivltests/module_nonansi_struct2.v new file mode 100644 index 000000000..70ee10bee --- /dev/null +++ b/ivtest/ivltests/module_nonansi_struct2.v @@ -0,0 +1,21 @@ +// Check that it is possible to declare the data type for a struct type module +// port before the direction for non-ANSI style port declarations. + +typedef struct packed { + reg [31:0] x; + reg [7:0] y; +} T; + +module test(x); + T x; + output x; + + initial begin + if ($bits(x) == $bits(T)) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_vec1.v b/ivtest/ivltests/module_nonansi_vec1.v new file mode 100644 index 000000000..96ab63a89 --- /dev/null +++ b/ivtest/ivltests/module_nonansi_vec1.v @@ -0,0 +1,17 @@ +// Check that it is possible to declare the data type for a vector type module +// port separately from the direction for non-ANSI style port declarations. +// declarations. + +module test(x); + output [7:0] x; + reg [7:0] x; + + initial begin + if ($bits(x) == 8) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/module_nonansi_vec2.v b/ivtest/ivltests/module_nonansi_vec2.v new file mode 100644 index 000000000..1663553ef --- /dev/null +++ b/ivtest/ivltests/module_nonansi_vec2.v @@ -0,0 +1,16 @@ +// Check that it is possible to declare the data type for a vector type module +// port before the direction for non-ANSI style port declarations. + +module test(x); + reg [7:0] x; + output [7:0] x; + + initial begin + if ($bits(x) == 8) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 278d6a3fa..9c23ae288 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -312,6 +312,14 @@ localparam_type2 normal,-g2009 ivltests logical_short_circuit normal,-g2012 ivltests logp2 normal,-g2005-sv ivltests mod_inst_pkg normal,-g2009 ivltests +module_nonansi_enum1 normal,-g2005-sv ivltests +module_nonansi_enum2 normal,-g2005-sv ivltests +module_nonansi_parray1 normal,-g2005-sv ivltests +module_nonansi_parray2 normal,-g2005-sv ivltests +module_nonansi_real1 normal,-g2005-sv ivltests +module_nonansi_real2 normal,-g2005-sv ivltests +module_nonansi_struct1 normal,-g2005-sv ivltests +module_nonansi_struct2 normal,-g2005-sv ivltests module_output_port_sv_var1 normal,-g2005-sv ivltests module_output_port_sv_var2 normal,-g2005-sv ivltests named_begin normal,-g2009 ivltests diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index 8ca0f666f..b78834162 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -647,6 +647,8 @@ module3.12A normal ivltests main module3.12B normal ivltests module_inout_port_type CE ivltests module_input_port_type CE ivltests +module_nonansi_vec1 normal ivltests +module_nonansi_vec2 normal ivltests module_output_port_var1 normal ivltests module_output_port_var2 normal ivltests module_port_range_mismatch CE ivltests