diff options
| author | Jim Lawson | 2016-12-19 10:20:48 -0800 |
|---|---|---|
| committer | GitHub | 2016-12-19 10:20:48 -0800 |
| commit | dd4650d29ed18ec610ad7561f4e9c990ba887a3d (patch) | |
| tree | 333fe66fba7ea7337fa1f6ffe1ec905cd2f724f3 /chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala | |
| parent | 207da69768dac464a719a7c712f6977371f7c5f4 (diff) | |
| parent | 0233f704e83d380b1fe8311dfffa3f44f74b506b (diff) | |
Merge branch 'master' into exceptionfix
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/ChiselAnnotation.scala | 30 |
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) + } + } +} |
