[prim_mubi] Add assertion to check that the values are complementary
Signed-off-by: Michael Schaffner <msf@google.com>
diff --git a/hw/ip/prim/rtl/prim_mubi_pkg.sv b/hw/ip/prim/rtl/prim_mubi_pkg.sv
index b0b3e83..2285e0f 100644
--- a/hw/ip/prim/rtl/prim_mubi_pkg.sv
+++ b/hw/ip/prim/rtl/prim_mubi_pkg.sv
@@ -10,6 +10,8 @@
// This package defines common multibit signal types, active high and active low values and
// the corresponding functions to test whether the values are set or not.
+`include "prim_assert.sv"
+
package prim_mubi_pkg;
//////////////////////////////////////////////
@@ -22,6 +24,9 @@
MuBi4False = 4'h5 // disabled
} mubi4_t;
+ // This is a prerequisite for the multibit functions below to work.
+ `ASSERT_STATIC_IN_PACKAGE(CheckMuBi4ValsComplementary_A, MuBi4True == ~MuBi4False)
+
// Test whether the value is supplied is one of the valid enumerations
function automatic logic mubi4_test_invalid(mubi4_t val);
return ~(val inside {MuBi4True, MuBi4False});
@@ -151,6 +156,9 @@
MuBi8False = 8'hA5 // disabled
} mubi8_t;
+ // This is a prerequisite for the multibit functions below to work.
+ `ASSERT_STATIC_IN_PACKAGE(CheckMuBi8ValsComplementary_A, MuBi8True == ~MuBi8False)
+
// Test whether the value is supplied is one of the valid enumerations
function automatic logic mubi8_test_invalid(mubi8_t val);
return ~(val inside {MuBi8True, MuBi8False});
@@ -280,6 +288,9 @@
MuBi12False = 12'h5A5 // disabled
} mubi12_t;
+ // This is a prerequisite for the multibit functions below to work.
+ `ASSERT_STATIC_IN_PACKAGE(CheckMuBi12ValsComplementary_A, MuBi12True == ~MuBi12False)
+
// Test whether the value is supplied is one of the valid enumerations
function automatic logic mubi12_test_invalid(mubi12_t val);
return ~(val inside {MuBi12True, MuBi12False});
@@ -409,6 +420,9 @@
MuBi16False = 16'hA5A5 // disabled
} mubi16_t;
+ // This is a prerequisite for the multibit functions below to work.
+ `ASSERT_STATIC_IN_PACKAGE(CheckMuBi16ValsComplementary_A, MuBi16True == ~MuBi16False)
+
// Test whether the value is supplied is one of the valid enumerations
function automatic logic mubi16_test_invalid(mubi16_t val);
return ~(val inside {MuBi16True, MuBi16False});
diff --git a/util/design/data/prim_mubi_pkg.sv.tpl b/util/design/data/prim_mubi_pkg.sv.tpl
index 855e925..4845780 100644
--- a/util/design/data/prim_mubi_pkg.sv.tpl
+++ b/util/design/data/prim_mubi_pkg.sv.tpl
@@ -10,6 +10,8 @@
// This package defines common multibit signal types, active high and active low values and
// the corresponding functions to test whether the values are set or not.
+`include "prim_assert.sv"
+
package prim_mubi_pkg;
<%
@@ -29,6 +31,9 @@
MuBi${nbits}False = ${nbits}'h${prim_mubi.mubi_value_as_hexstr(False, nbits)} // disabled
} mubi${nbits}_t;
+ // This is a prerequisite for the multibit functions below to work.
+ `ASSERT_STATIC_IN_PACKAGE(CheckMuBi${nbits}ValsComplementary_A, MuBi${nbits}True == ~MuBi${nbits}False)
+
// Test whether the value is supplied is one of the valid enumerations
function automatic logic mubi${nbits}_test_invalid(mubi${nbits}_t val);
return ~(val inside {MuBi${nbits}True, MuBi${nbits}False});