summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSequencer2020-04-10 14:51:41 +0000
committerGitHub2020-04-10 10:51:41 -0400
commit2b71a50abcf71ff2f90802ba1b06d94428e550f1 (patch)
tree570a018687be9d99bc02992e527c3d3541e216ee /core
parente55c00fe09a795adae15b6383a75300d6cfa9e7a (diff)
Expose checkTypeEquivalence as a public API (#1402)
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/chisel3/Data.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/src/main/scala/chisel3/Data.scala b/core/src/main/scala/chisel3/Data.scala
index 6574a39d..93fccaec 100644
--- a/core/src/main/scala/chisel3/Data.scala
+++ b/core/src/main/scala/chisel3/Data.scala
@@ -131,6 +131,23 @@ package experimental {
target.direction
}
+ /** Check if two Chisel types are the same type.
+ * Internally, this is dispatched to each Chisel type's
+ * `typeEquivalent` function for each type to determine
+ * if the types are intended to be equal.
+ *
+ * For most types, different parameters should ensure
+ * that the types are different.
+ * For example, `UInt(8.W)` and `UInt(16.W)` are different.
+ * Likewise, Records check that both Records have the same
+ * elements with the same types.
+ *
+ * @param x First Chisel type
+ * @param y Second Chisel type
+ * @return true if the two Chisel types are equal.
+ **/
+ def checkTypeEquivalence(x: Data, y: Data): Boolean = x.typeEquivalent(y)
+
// Returns the top-level module ports
// TODO: maybe move to something like Driver or DriverUtils, since this is mainly for interacting
// with compiled artifacts (vs. elaboration-time reflection)?