summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util
diff options
context:
space:
mode:
authorJack Koenig2018-02-28 17:40:53 -0800
committerGitHub2018-02-28 17:40:53 -0800
commit46553432aaf65cff131e59081d57dabe16c2ab55 (patch)
tree2a64125046b36808a5a89c18f98204394c27ccd8 /src/main/scala/chisel3/util
parent97871178cb511063965f971b768f91c289c4776f (diff)
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
Diffstat (limited to 'src/main/scala/chisel3/util')
-rw-r--r--src/main/scala/chisel3/util/BlackBoxUtils.scala17
1 files changed, 12 insertions, 5 deletions
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)
}
}