aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/transforms/Dedup.scala
diff options
context:
space:
mode:
authorJack Koenig2018-02-27 18:07:11 -0800
committerGitHub2018-02-27 18:07:11 -0800
commitc7eb1570dfb1c7701ea32d1209982a053f3cec1d (patch)
tree3f509b202d82841c5dad5588d1f953a25d389b44 /src/main/scala/firrtl/transforms/Dedup.scala
parentb90fc784a1819c1d7905910130a7da022214bc22 (diff)
Refactor Annotations (#721)
- Old Annotation renamed to deprecated LegacyAnnotation - Annotation is now a trait that can be extended - New JsonProtocol for Annotation [de]serialization - Replace AnnotationMap with AnnotationSeq - Deprecate Transform.getMyAnnotations - Update Transforms - Turn on deprecation warnings - Remove deprecated Driver.compile - Make AnnotationTests abstract with Legacy and Json subclasses - Add functionality to convert LegacyAnnotations of built-in annos This will give a noisy warning and is more of a best effort than a robust solution. Fixes #475 Closes #609
Diffstat (limited to 'src/main/scala/firrtl/transforms/Dedup.scala')
-rw-r--r--src/main/scala/firrtl/transforms/Dedup.scala12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/main/scala/firrtl/transforms/Dedup.scala b/src/main/scala/firrtl/transforms/Dedup.scala
index 717481b9..f22415f0 100644
--- a/src/main/scala/firrtl/transforms/Dedup.scala
+++ b/src/main/scala/firrtl/transforms/Dedup.scala
@@ -14,16 +14,10 @@ import scala.collection.mutable
/** A component, e.g. register etc. Must be declared only once under the TopAnnotation
*/
-object NoDedupAnnotation {
- def apply(target: ModuleName): Annotation = Annotation(target, classOf[DedupModules], s"nodedup!")
-
- def unapply(a: Annotation): Option[ModuleName] = a match {
- case Annotation(ModuleName(n, c), _, "nodedup!") => Some(ModuleName(n, c))
- case _ => None
- }
+case class NoDedupAnnotation(target: ModuleName) extends SingleTargetAnnotation[ModuleName] {
+ def duplicate(n: ModuleName) = NoDedupAnnotation(n)
}
-
// Only use on legal Firrtl. Specifically, the restriction of
// instance loops must have been checked, or else this pass can
// infinitely recurse
@@ -150,7 +144,7 @@ class DedupModules extends Transform {
}
def execute(state: CircuitState): CircuitState = {
- val noDedups = getMyAnnotations(state).collect { case NoDedupAnnotation(ModuleName(m, c)) => m }
+ val noDedups = state.annotations.collect { case NoDedupAnnotation(ModuleName(m, c)) => m }
val (newC, renameMap) = run(state.circuit, noDedups)
state.copy(circuit = newC, renames = Some(renameMap))
}