aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/Annotations.scala
diff options
context:
space:
mode:
authorjackkoenig2016-10-20 00:19:01 -0700
committerJack Koenig2016-11-04 13:29:09 -0700
commit8fa9429a6e916ab2a789f5d81fa803b022805b52 (patch)
treefac2efcbd0a68bfb1916f09afc7f003c7a3d6528 /src/main/scala/firrtl/Annotations.scala
parent62133264a788f46b319ebab9c31424b7e0536101 (diff)
Refactor Compilers and Transforms
* Transform Ids now handled by Class[_ <: Transform] instead of magic numbers * Transforms define inputForm and outputForm * Custom transforms can be inserted at runtime into compiler or the Driver * Current "built-in" custom transforms handled via above mechanism * Verilog-specific passes moved to the Verilog emitter
Diffstat (limited to 'src/main/scala/firrtl/Annotations.scala')
-rw-r--r--src/main/scala/firrtl/Annotations.scala28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/main/scala/firrtl/Annotations.scala b/src/main/scala/firrtl/Annotations.scala
index d47ce67e..d70732e6 100644
--- a/src/main/scala/firrtl/Annotations.scala
+++ b/src/main/scala/firrtl/Annotations.scala
@@ -115,12 +115,6 @@ object Annotations {
}
/**
- * Transform ID (TransID) associates an annotation with an instantiated
- * Firrtl compiler transform
- */
- case class TransID(id: Int)
-
- /**
* Permissibility defines the range of acceptable changes to the annotated component.
*/
trait Permissibility {
@@ -215,7 +209,7 @@ object Annotations {
/**
* Annotation associates with a given named circuit component (target) and a
- * given transformation (tID). Also defined are the legal ranges of changes
+ * given transformation (transform). Also defined are the legal ranges of changes
* to the associated component (Permissibility) and how the annotation
* propagates under such changes (Tenacity). Subclasses must implement the
* duplicate function to create the same annotation associated with a new
@@ -223,7 +217,7 @@ object Annotations {
*/
trait Annotation extends Permissibility with Tenacity {
def target: Named
- def tID: TransID
+ def transform: Class[_ <: Transform]
protected def duplicate(n: Named): Annotation
def serialize: String = this.toString
def update(tos: Seq[Named]): Seq[Annotation] = {
@@ -236,23 +230,23 @@ object Annotations {
* Container of all annotations for a Firrtl compiler.
*/
case class AnnotationMap(annotations: Seq[Annotation]) {
- type NamedMap = Map[Named, Map[TransID, Annotation]]
- type IDMap = Map[TransID, Map[Named, Annotation]]
+ type NamedMap = Map[Named, Map[Class[_], Annotation]]
+ type IDMap = Map[Class[_], Map[Named, Annotation]]
val (namedMap: NamedMap, idMap:IDMap) =
//annotations.foldLeft(Tuple2[NamedMap, IDMap](Map.empty, Map.empty)){
annotations.foldLeft((Map.empty: NamedMap, Map.empty: IDMap)){
(partialMaps: (NamedMap, IDMap), annotation: Annotation) => {
- val tIDToAnn = partialMaps._1.getOrElse(annotation.target, Map.empty)
- val pNMap = partialMaps._1 + (annotation.target -> (tIDToAnn + (annotation.tID -> annotation)))
+ val transformToAnn = partialMaps._1.getOrElse(annotation.target, Map.empty)
+ val pNMap = partialMaps._1 + (annotation.target -> (transformToAnn + (annotation.transform -> annotation)))
- val nToAnn = partialMaps._2.getOrElse(annotation.tID, Map.empty)
- val ptIDMap = partialMaps._2 + (annotation.tID -> (nToAnn + (annotation.target -> annotation)))
- Tuple2(pNMap, ptIDMap)
+ val nToAnn = partialMaps._2.getOrElse(annotation.transform, Map.empty)
+ val ptransformMap = partialMaps._2 + (annotation.transform -> (nToAnn + (annotation.target -> annotation)))
+ Tuple2(pNMap, ptransformMap)
}
}
- def get(id: TransID): Option[Map[Named, Annotation]] = idMap.get(id)
- def get(named: Named): Option[Map[TransID, Annotation]] = namedMap.get(named)
+ def get(id: Class[_]): Option[Map[Named, Annotation]] = idMap.get(id)
+ def get(named: Named): Option[Map[Class[_], Annotation]] = namedMap.get(named)
}
}