From cf5019e2d2208099445c1f7e0530a86abf0efabc Mon Sep 17 00:00:00 2001 From: Kevin Laeufer Date: Mon, 26 Jul 2021 18:09:06 -0700 Subject: ir: make HashCode.toHashString public (#2302) This will allow chiseltest to save the hash code to disk for the purpose of caching simulation binaries.--- src/test/scala/firrtl/ir/StructuralHashSpec.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/test') 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)))) -- cgit v1.2.3