From b57c04587675aad119dc151f1a7ba8f98ed8d8ae Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Fri, 19 Jun 2020 16:55:11 -0700 Subject: [PATCH] Memoize the hashcode of the ChiselCircuitAnnotation (#1485) (cherry picked from commit 9bda7a75686e075df038b2c24fbd30ad8ae0d941) --- src/main/scala/chisel3/stage/ChiselAnnotations.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/scala/chisel3/stage/ChiselAnnotations.scala b/src/main/scala/chisel3/stage/ChiselAnnotations.scala index 11697d7debb..e49064566ec 100644 --- a/src/main/scala/chisel3/stage/ChiselAnnotations.scala +++ b/src/main/scala/chisel3/stage/ChiselAnnotations.scala @@ -90,7 +90,12 @@ object ChiselGeneratorAnnotation extends HasShellOptions { /** Stores a Chisel Circuit * @param circuit a Chisel Circuit */ -case class ChiselCircuitAnnotation(circuit: Circuit) extends NoTargetAnnotation with ChiselOption +case class ChiselCircuitAnnotation(circuit: Circuit) extends NoTargetAnnotation with ChiselOption { + /* Caching the hashCode for a large circuit is necessary due to repeated queries. + * Not caching the hashCode will cause severe performance degredations for large [[Circuit]]s. + */ + override lazy val hashCode: Int = circuit.hashCode +} case class ChiselOutputFileAnnotation(file: String) extends NoTargetAnnotation with ChiselOption