diff options
| author | Jack Koenig | 2018-02-27 18:07:11 -0800 |
|---|---|---|
| committer | GitHub | 2018-02-27 18:07:11 -0800 |
| commit | c7eb1570dfb1c7701ea32d1209982a053f3cec1d (patch) | |
| tree | 3f509b202d82841c5dad5588d1f953a25d389b44 /src/main/scala/firrtl/transforms/Flatten.scala | |
| parent | b90fc784a1819c1d7905910130a7da022214bc22 (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/Flatten.scala')
| -rw-r--r-- | src/main/scala/firrtl/transforms/Flatten.scala | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/main/scala/firrtl/transforms/Flatten.scala b/src/main/scala/firrtl/transforms/Flatten.scala index cc40c569..6654667a 100644 --- a/src/main/scala/firrtl/transforms/Flatten.scala +++ b/src/main/scala/firrtl/transforms/Flatten.scala @@ -10,13 +10,8 @@ import scala.collection.mutable import firrtl.passes.{InlineInstances,PassException} /** Tags an annotation to be consumed by this transform */ -object FlattenAnnotation { - def apply(target: Named): Annotation = Annotation(target, classOf[Flatten], "") - - def unapply(a: Annotation): Option[Named] = a match { - case Annotation(named, t, _) if t == classOf[Flatten] => Some(named) - case _ => None - } +case class FlattenAnnotation(target: Named) extends SingleTargetAnnotation[Named] { + def duplicate(n: Named) = FlattenAnnotation(n) } /** @@ -39,7 +34,7 @@ class Flatten extends Transform { }.toSet, instNames) case FlattenAnnotation(ModuleName(mod, cir)) => (modNames + ModuleName(mod, cir), instNames) case FlattenAnnotation(ComponentName(com, mod)) => (modNames, instNames + ComponentName(com, mod)) - case _ => throw new PassException("Annotation must be InlineDeepAnnotation") + case _ => throw new PassException("Annotation must be a FlattenAnnotation") } } @@ -107,7 +102,8 @@ class Flatten extends Transform { } override def execute(state: CircuitState): CircuitState = { - getMyAnnotations(state) match { + val annos = state.annotations.collect { case a @ FlattenAnnotation(_) => a } + annos match { case Nil => CircuitState(state.circuit, state.form) case myAnnotations => val c = state.circuit |
