diff options
| author | azidar | 2016-09-30 11:46:01 -0700 |
|---|---|---|
| committer | Jack Koenig | 2016-11-04 13:29:09 -0700 |
| commit | 1c36656fad15f515543d89a6407b360b4b2ebb87 (patch) | |
| tree | e115e2e565f4af78aa310dae169e2df2e20a9894 /src/test/scala/firrtlTests/transforms | |
| parent | 8fa9429a6e916ab2a789f5d81fa803b022805b52 (diff) | |
Add a pass to deduplicate modules
Diffstat (limited to 'src/test/scala/firrtlTests/transforms')
| -rw-r--r-- | src/test/scala/firrtlTests/transforms/DedupTests.scala | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/transforms/DedupTests.scala b/src/test/scala/firrtlTests/transforms/DedupTests.scala new file mode 100644 index 00000000..fac6a1fb --- /dev/null +++ b/src/test/scala/firrtlTests/transforms/DedupTests.scala @@ -0,0 +1,112 @@ +package firrtlTests +package transform + +import java.io.StringWriter + +import org.scalatest.FlatSpec +import org.scalatest.Matchers +import org.scalatest.junit.JUnitRunner + +import firrtl.ir.Circuit +import firrtl.Parser +import firrtl.passes.PassExceptions +import firrtl.Annotations.{ + Named, + CircuitName, + Annotation, + AnnotationMap +} +import firrtl.transforms.{DedupModules, DedupAnnotation} + + +/** + * Tests inline instances transformation + */ +class DedupModuleTests extends HighTransformSpec { + def transform = new DedupModules + "The module A" should "be deduped" in { + val input = + """circuit Top : + | module Top : + | inst a1 of A + | inst a2 of A_ + | module A : + | output x: UInt<1> + | x <= UInt(1) + | module A_ : + | output x: UInt<1> + | x <= UInt(1) + """.stripMargin + val check = + """circuit Top : + | module Top : + | inst a1 of A + | inst a2 of A + | module A : + | output x: UInt<1> + | x <= UInt(1) + """.stripMargin + val writer = new StringWriter() + val aMap = new AnnotationMap(Nil) + execute(writer, aMap, input, check) + } + "The module A and B" should "be deduped" in { + val input = + """circuit Top : + | module Top : + | inst a1 of A + | inst a2 of A_ + | module A : + | output x: UInt<1> + | inst b of B + | x <= b.x + | module A_ : + | output x: UInt<1> + | inst b of B_ + | x <= b.x + | module B : + | output x: UInt<1> + | x <= UInt(1) + | module B_ : + | output x: UInt<1> + | x <= UInt(1) + """.stripMargin + val check = + """circuit Top : + | module Top : + | inst a1 of A + | inst a2 of A + | module A : + | output x: UInt<1> + | inst b of B + | x <= b.x + | module B : + | output x: UInt<1> + | x <= UInt(1) + """.stripMargin + val writer = new StringWriter() + val aMap = new AnnotationMap(Nil) + execute(writer, aMap, input, check) + } +} + +// Execution driven tests for inlining modules +// TODO(izraelevitz) fix this test +//class InlineInstancesIntegrationSpec extends FirrtlPropSpec { +// // Shorthand for creating annotations to inline modules +// def inlineModules(names: Seq[String]): Seq[CircuitAnnotation] = +// Seq(StickyCircuitAnnotation(InlineCAKind, names.map(n => ModuleName(n) -> TagAnnotation).toMap)) +// +// case class Test(name: String, dir: String, ann: Seq[CircuitAnnotation]) +// +// val runTests = Seq( +// Test("GCDTester", "/integration", inlineModules(Seq("DecoupledGCD"))) +// ) +// +// runTests foreach { test => +// property(s"${test.name} should execute correctly with inlining") { +// println(s"Got annotations ${test.ann}") +// runFirrtlTest(test.name, test.dir, test.ann) +// } +// } +//} |
