aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorKevin Laeufer2021-07-26 18:09:06 -0700
committerGitHub2021-07-27 01:09:06 +0000
commitcf5019e2d2208099445c1f7e0530a86abf0efabc (patch)
tree36ff95691cfef67145cdd4e1dde29283bdad4ba8 /src/test/scala
parent2ca2bcc64426b701e7ae10cf88627c71c05b28b3 (diff)
ir: make HashCode.toHashString public (#2302)
This will allow chiseltest to save the hash code to disk for the purpose of caching simulation binaries.
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/firrtl/ir/StructuralHashSpec.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/scala/firrtl/ir/StructuralHashSpec.scala b/src/test/scala/firrtl/ir/StructuralHashSpec.scala
index ffd03126..4372cc70 100644
--- a/src/test/scala/firrtl/ir/StructuralHashSpec.scala
+++ b/src/test/scala/firrtl/ir/StructuralHashSpec.scala
@@ -38,6 +38,16 @@ class StructuralHashSpec extends AnyFlatSpec {
assert(hash(b1) != hash(UIntLiteral(1, IntWidth(2))))
}
+ it should "generate the same hash String if the objects are structurally the same" in {
+ assert(hash(b0).toHashString == hash(UIntLiteral(0, IntWidth(1))).toHashString)
+ assert(hash(b0).toHashString != hash(UIntLiteral(1, IntWidth(1))).toHashString)
+ assert(hash(b0).toHashString != hash(UIntLiteral(1, IntWidth(2))).toHashString)
+
+ assert(hash(b1).toHashString == hash(UIntLiteral(1, IntWidth(1))).toHashString)
+ assert(hash(b1).toHashString != hash(UIntLiteral(0, IntWidth(1))).toHashString)
+ assert(hash(b1).toHashString != hash(UIntLiteral(1, IntWidth(2))).toHashString)
+ }
+
it should "ignore expression types" in {
assert(hash(add) == hash(DoPrim(Add, Seq(b0, b1), Seq(), UnknownType)))
assert(hash(add) == hash(DoPrim(Add, Seq(b0, b1), Seq(), UIntType(UnknownWidth))))