From 83da384df36753a5d3cea59ec3c32777973b0088 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 19 Mar 2022 16:46:03 +0100 Subject: [PATCH] Add regression test for enum compatibility across module boundaries Check that the compatibility of signals of enum data type across module boundaries. If the enum data type is declared at a higher level scope or imported from a package the signals are compatible between different module instances. If the enum data type is declared within the module itself though the signals are not compatible. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/enum_compatibility1.v | 25 +++++++++++++++++++ ivtest/ivltests/enum_compatibility2.v | 30 +++++++++++++++++++++++ ivtest/ivltests/enum_compatibility3.v | 30 +++++++++++++++++++++++ ivtest/ivltests/enum_compatibility_fail.v | 21 ++++++++++++++++ ivtest/regress-sv.list | 4 +++ 5 files changed, 110 insertions(+) create mode 100644 ivtest/ivltests/enum_compatibility1.v create mode 100644 ivtest/ivltests/enum_compatibility2.v create mode 100644 ivtest/ivltests/enum_compatibility3.v create mode 100644 ivtest/ivltests/enum_compatibility_fail.v diff --git a/ivtest/ivltests/enum_compatibility1.v b/ivtest/ivltests/enum_compatibility1.v new file mode 100644 index 000000000..25beb89f9 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility1.v @@ -0,0 +1,25 @@ +// Check that enum types declared in a higher level scope are compatible between +// different instances of a module. + +typedef enum integer { + A +} T; + +module M; + T e; +endmodule + +module test; + M m1(); + M m2(); + + initial begin + m1.e = A; + m2.e = m1.e; + if (m2.e === A) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end +endmodule diff --git a/ivtest/ivltests/enum_compatibility2.v b/ivtest/ivltests/enum_compatibility2.v new file mode 100644 index 000000000..f98a35489 --- /dev/null +++ b/ivtest/ivltests/enum_compatibility2.v @@ -0,0 +1,30 @@ +// Check that enum types explicitly imported from a package are compatible +// between different instances of a module. + +package P; + typedef enum integer { + A + } T; +endpackage + +module M; + import P::T; + T e; +endmodule + +module test; + import P::A; + + M m1(); + M m2(); + + initial begin + m1.e = A; + m2.e = m1.e; + if (m2.e === A) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end +endmodule diff --git a/ivtest/ivltests/enum_compatibility3.v b/ivtest/ivltests/enum_compatibility3.v new file mode 100644 index 000000000..6395009ad --- /dev/null +++ b/ivtest/ivltests/enum_compatibility3.v @@ -0,0 +1,30 @@ +// Check that enum types implicitly imported from a package are compatible +// between different instances of a module. + +package P; + typedef enum integer { + A + } T; +endpackage + +module M; + import P::*; + T e; +endmodule + +module test; + import P::*; + + M m1(); + M m2(); + + initial begin + m1.e = A; + m2.e = m1.e; + if (m2.e === A) 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_fail.v new file mode 100644 index 000000000..169c1263d --- /dev/null +++ b/ivtest/ivltests/enum_compatibility_fail.v @@ -0,0 +1,21 @@ +// Check that enums declared within a module are not compatible between +// different instances of a module + +module M; + + enum integer { + A + } e; + +endmodule + +module test; + M m1(); + M m2(); + + initial begin + // These are different types and not compatible + m1.e = m2.e; + $display("FAILED"); + end +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 278d6a3fa..5fd1b798a 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -232,6 +232,10 @@ disable_fork_cmd normal,-g2009 ivltests display_bug normal,-g2009 ivltests gold=display_bug.gold edge normal,-g2009 ivltests enum_base_range 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_elem_ranges normal,-g2005-sv ivltests enum_dims_invalid CE,-g2005-sv ivltests enum_in_struct normal,-g2005-sv ivltests