From 9bda7a75686e075df038b2c24fbd30ad8ae0d941 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Fri, 19 Jun 2020 16:55:11 -0700 Subject: Memoize the hashcode of the ChiselCircuitAnnotation (#1485) --- src/main/scala/chisel3/stage/ChiselAnnotations.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/scala/chisel3/stage/ChiselAnnotations.scala b/src/main/scala/chisel3/stage/ChiselAnnotations.scala index 11697d7d..e4906456 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 -- cgit v1.2.3