diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/chisel3/stage/phases/AddImplicitOutputAnnotationFile.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/stage/phases/AddImplicitOutputAnnotationFile.scala b/src/main/scala/chisel3/stage/phases/AddImplicitOutputAnnotationFile.scala new file mode 100644 index 00000000..de251ab6 --- /dev/null +++ b/src/main/scala/chisel3/stage/phases/AddImplicitOutputAnnotationFile.scala @@ -0,0 +1,25 @@ +// See LICENSE for license details. + +package chisel3.stage.phases + +import chisel3.stage.ChiselCircuitAnnotation +import firrtl.AnnotationSeq +import firrtl.options.{OutputAnnotationFileAnnotation, Phase} + +/** Adds an [[firrtl.options.OutputAnnotationFileAnnotation]] if one does not exist. This replicates old behavior where + * an output annotation file was always written. + */ +class AddImplicitOutputAnnotationFile extends Phase { + + def transform(annotations: AnnotationSeq): AnnotationSeq = annotations + .collectFirst{ case _: OutputAnnotationFileAnnotation => annotations } + .getOrElse{ + + val x: Option[AnnotationSeq] = annotations + .collectFirst{ case a: ChiselCircuitAnnotation => + OutputAnnotationFileAnnotation(a.circuit.name) +: annotations } + + x.getOrElse(annotations) + } + +} |
