summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/chisel3/StrongEnum.scala6
-rw-r--r--core/src/main/scala/chisel3/internal/Builder.scala6
2 files changed, 10 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/StrongEnum.scala b/core/src/main/scala/chisel3/StrongEnum.scala
index 3c9f4105..c1967949 100644
--- a/core/src/main/scala/chisel3/StrongEnum.scala
+++ b/core/src/main/scala/chisel3/StrongEnum.scala
@@ -240,11 +240,13 @@ abstract class EnumType(private[chisel3] val factory: EnumFactory, selfAnnotatin
case None => EnumComponentChiselAnnotation(this, enumTypeName)
}
- if (!Builder.annotations.contains(anno)) {
+ if (!Builder.enumAnnos.contains(anno)) {
+ Builder.enumAnnos += anno
annotate(anno)
}
- if (!Builder.annotations.contains(factory.globalAnnotation)) {
+ if (!Builder.enumAnnos.contains(factory.globalAnnotation)) {
+ Builder.enumAnnos += factory.globalAnnotation
annotate(factory.globalAnnotation)
}
}
diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala
index d06b7992..fe7d7bea 100644
--- a/core/src/main/scala/chisel3/internal/Builder.scala
+++ b/core/src/main/scala/chisel3/internal/Builder.scala
@@ -485,6 +485,10 @@ private[chisel3] class DynamicContext(
val newAnnotations = ArrayBuffer[ChiselMultiAnnotation]()
var currentModule: Option[BaseModule] = None
+ // Enum annotations are added every time a StrongEnum is bound
+ // To keep the number down, we keep them unique in the annotations
+ val enumAnnos = mutable.HashSet[ChiselAnnotation]()
+
/** Contains a mapping from a elaborated module to their aspect
* Set by [[ModuleAspect]]
*/
@@ -553,6 +557,8 @@ private[chisel3] object Builder extends LazyLogging {
def components: ArrayBuffer[Component] = dynamicContext.components
def annotations: ArrayBuffer[ChiselAnnotation] = dynamicContext.annotations
+ def enumAnnos: mutable.HashSet[ChiselAnnotation] = dynamicContext.enumAnnos
+
// TODO : Unify this with annotations in the future - done this way for backward compatability
def newAnnotations: ArrayBuffer[ChiselMultiAnnotation] = dynamicContext.newAnnotations