From 46553432aaf65cff131e59081d57dabe16c2ab55 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Wed, 28 Feb 2018 17:40:53 -0800 Subject: Refactor Annotations (#767) * Generalize ChiselAnnotation This allows us to delay creation of Annotations till elaboration is complete. Also update all annotation-related code. * Add RunFirrtlTransform Use a Chisel-specific RunFirrtlTransform API to preserve behavior of old ChiselAnnotation (now called ChiselLegacyAnnotation) * Use unique test directories in ChiselRunners.compile--- src/main/scala/chisel3/util/BlackBoxUtils.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/main/scala/chisel3/util') diff --git a/src/main/scala/chisel3/util/BlackBoxUtils.scala b/src/main/scala/chisel3/util/BlackBoxUtils.scala index fbcf4a59..fa62184a 100644 --- a/src/main/scala/chisel3/util/BlackBoxUtils.scala +++ b/src/main/scala/chisel3/util/BlackBoxUtils.scala @@ -3,14 +3,18 @@ package chisel3.util import chisel3._ -import chisel3.core.ChiselAnnotation -import firrtl.transforms.{BlackBoxInline, BlackBoxResource, BlackBoxSourceHelper} +import chisel3.experimental.{ChiselAnnotation, RunFirrtlTransform} +import firrtl.transforms.{BlackBoxResourceAnno, BlackBoxInlineAnno, BlackBoxSourceHelper} trait HasBlackBoxResource extends BlackBox { self: BlackBox => def setResource(blackBoxResource: String): Unit = { - annotate(ChiselAnnotation(self, classOf[BlackBoxSourceHelper], BlackBoxResource(blackBoxResource).serialize)) + val anno = new ChiselAnnotation with RunFirrtlTransform { + def toFirrtl = BlackBoxResourceAnno(self.toNamed, blackBoxResource) + def transformClass = classOf[BlackBoxSourceHelper] + } + chisel3.experimental.annotate(anno) } } @@ -18,7 +22,10 @@ trait HasBlackBoxInline extends BlackBox { self: BlackBox => def setInline(blackBoxName: String, blackBoxInline: String): Unit = { - annotate(ChiselAnnotation( - self, classOf[BlackBoxSourceHelper], BlackBoxInline(blackBoxName, blackBoxInline).serialize)) + val anno = new ChiselAnnotation with RunFirrtlTransform { + def toFirrtl = BlackBoxInlineAnno(self.toNamed, blackBoxName, blackBoxInline) + def transformClass = classOf[BlackBoxSourceHelper] + } + chisel3.experimental.annotate(anno) } } -- cgit v1.2.3