summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala
diff options
context:
space:
mode:
authorChick Markley2016-12-07 10:31:23 -0800
committerGitHub2016-12-07 10:31:23 -0800
commitad53161bbb9f67e16b88ca7a508a537f88d77e05 (patch)
treed041b864ff72f5a3f171e98780200361ea961f2c /chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala
parent9aba55e7452981058d069b3096544d45e730dba9 (diff)
Support for creating chisel annotations that are consumed by firrtl (#393)
* Support for creating chisel annotations that are consumed by firrtl Update annotation serialization in Driver Add DiamondAnnotation Spec that illustrates how to do simple annotations frontEnd must have dependency on firrtl Add annotation method to Module Circuit has extra optional parameter that is Seq of Annotations In Builder add annotation buffer to DynamicContext to store annotations created in modules Added explicit types on naming api methods to avoid type confusion Because some names are not available until elaboration create intermediate ChiselAnnotation that gets turned into a firrtl Annotation after elaboration In execute pass firrtl text and annotation to firrtl are now passed in through optionManager, though intermediate file .fir and .anno files are still created for inspection and/or later use * Somehow missed ChiselAnnotation * fixes for Jack's review of PR
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala b/chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala
new file mode 100644
index 00000000..73573bb1
--- /dev/null
+++ b/chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala
@@ -0,0 +1,30 @@
+// See LICENSE for license details.
+
+package chisel3.core
+
+import chisel3.internal.InstanceId
+import firrtl.Transform
+import firrtl.annotations.{Annotation, CircuitName, ComponentName, ModuleName}
+
+/**
+ * This is a stand-in for the firrtl.Annotations.Annotation because at the time this annotation
+ * is created the component cannot be resolved, into a targetString. Resolution can only
+ * happen after the circuit is elaborated
+ * @param component A chisel thingy to be annotated, could be module, wire, reg, etc.
+ * @param transformClass A fully-qualified class name of the transformation pass
+ * @param value A string value to be used by the transformation pass
+ */
+case class ChiselAnnotation(component: InstanceId, transformClass: Class[_ <: Transform], value: String) {
+ def toFirrtl: Annotation = {
+ val circuitName = CircuitName(component.pathName.split("""\.""").head)
+ component match {
+ case m: Module =>
+ Annotation(
+ ModuleName(m.name, circuitName), transformClass, value)
+ case _ =>
+ Annotation(
+ ComponentName(
+ component.instanceName, ModuleName(component.parentModName, circuitName)), transformClass, value)
+ }
+ }
+}