summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/chiselTests/stage/phases/ElaborateSpec.scala46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/stage/phases/ElaborateSpec.scala b/src/test/scala/chiselTests/stage/phases/ElaborateSpec.scala
new file mode 100644
index 00000000..4d99b24c
--- /dev/null
+++ b/src/test/scala/chiselTests/stage/phases/ElaborateSpec.scala
@@ -0,0 +1,46 @@
+// See LICENSE for license details.
+
+package chiselTests.stage.phases
+
+import org.scalatest.{FlatSpec, Matchers}
+
+import chisel3._
+import chisel3.stage.{ChiselCircuitAnnotation, ChiselGeneratorAnnotation}
+import chisel3.stage.phases.Elaborate
+
+import firrtl.options.Phase
+
+class ElaborateSpec extends FlatSpec with Matchers {
+
+ class Foo extends Module {
+ override def desiredName: String = "Foo"
+ val io = IO(
+ new Bundle {
+ val in = Input(Bool())
+ val out = Output(Bool())
+ })
+
+ io.out := ~io.in
+ }
+
+ class Bar extends Foo {
+ override def desiredName: String = "Bar"
+ }
+
+ class Fixture { val phase: Phase = new Elaborate }
+
+ behavior of classOf[Elaborate].toString
+
+ it should "expand ChiselGeneratorAnnotations into ChiselCircuitAnnotations and delete originals" in new Fixture {
+ val annotations = Seq( ChiselGeneratorAnnotation(() => new Foo),
+ ChiselGeneratorAnnotation(() => new Bar) )
+ val out = phase.transform(annotations)
+
+ info("original annotations removed")
+ out.collect{ case a: ChiselGeneratorAnnotation => a } should be (empty)
+
+ info("circuits created with the expected names")
+ out.collect{ case a: ChiselCircuitAnnotation => a.circuit.name } should be (Seq("Foo", "Bar"))
+ }
+
+}