diff options
| author | Kevin Laeufer | 2021-07-26 18:09:06 -0700 |
|---|---|---|
| committer | GitHub | 2021-07-27 01:09:06 +0000 |
| commit | cf5019e2d2208099445c1f7e0530a86abf0efabc (patch) | |
| tree | 36ff95691cfef67145cdd4e1dde29283bdad4ba8 /src/main/scala | |
| parent | 2ca2bcc64426b701e7ae10cf88627c71c05b28b3 (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/main/scala')
| -rw-r--r-- | src/main/scala/firrtl/ir/StructuralHash.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/ir/StructuralHash.scala b/src/main/scala/firrtl/ir/StructuralHash.scala index 20c63e4e..26e7d210 100644 --- a/src/main/scala/firrtl/ir/StructuralHash.scala +++ b/src/main/scala/firrtl/ir/StructuralHash.scala @@ -115,16 +115,20 @@ object StructuralHash { } trait HashCode { - protected val str: String - override def hashCode(): Int = str.hashCode + + /** String representation of the hash code. + * Two instances of [[HashCode]] are equal if and only if their toHashString values are equal. + */ + def toHashString: String + override def hashCode(): Int = toHashString.hashCode override def equals(obj: Any): Boolean = obj match { - case hashCode: HashCode => this.str.equals(hashCode.str) + case hashCode: HashCode => this.toHashString.equals(hashCode.toHashString) case _ => false } } private class MDHashCode(code: Array[Byte]) extends HashCode { - protected override val str: String = code.map(b => f"${b.toInt & 0xff}%02x").mkString("") + override val toHashString: String = code.map(b => f"${b.toInt & 0xff}%02x").mkString("") } /** Generic hashing interface which allows us to use different backends to trade of speed and collision resistance */ |
