aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAndrey Ayupov2017-08-04 11:02:41 -0700
committerAdam Izraelevitz2017-08-04 11:02:41 -0700
commita84956afa36dbe29e87dd6c2168848a426ec42d3 (patch)
treef16697471871b7a2b9f65f8bbe8c7271bd26feb7 /src/test
parent86f7abd4d63a33bbb0012fa254b01edf10ba2159 (diff)
bug fix for cases when we want to flatten a module in which a module is instantiated multiple times (#634)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/FlattenTests.scala41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/test/scala/firrtlTests/FlattenTests.scala b/src/test/scala/firrtlTests/FlattenTests.scala
index f695cf4a..10988f8f 100644
--- a/src/test/scala/firrtlTests/FlattenTests.scala
+++ b/src/test/scala/firrtlTests/FlattenTests.scala
@@ -26,7 +26,6 @@ class FlattenTests extends LowTransformSpec {
FlattenAnnotation(name)
}
-
"The modules inside Top " should "be inlined" in {
val input =
"""circuit Top :
@@ -56,6 +55,46 @@ class FlattenTests extends LowTransformSpec {
| b <= a""".stripMargin
execute(input, check, Seq(flatten("Top")))
}
+
+ "Two instances of the same module inside Top " should "be inlined" in {
+ val input =
+ """circuit Top :
+ | module Top :
+ | input a : UInt<32>
+ | output b : UInt<32>
+ | inst i1 of Inline1
+ | inst i2 of Inline1
+ | wire tmp : UInt<32>
+ | i1.a <= a
+ | tmp <= i1.b
+ | i2.a <= tmp
+ | b <= i2.b
+ | module Inline1 :
+ | input a : UInt<32>
+ | output b : UInt<32>
+ | b <= a""".stripMargin
+ val check =
+ """circuit Top :
+ | module Top :
+ | input a : UInt<32>
+ | output b : UInt<32>
+ | wire i1$a : UInt<32>
+ | wire i1$b : UInt<32>
+ | i1$b <= i1$a
+ | wire i2$a : UInt<32>
+ | wire i2$b : UInt<32>
+ | i2$b <= i2$a
+ | wire tmp : UInt<32>
+ | b <= i2$b
+ | tmp <= i1$b
+ | i1$a <= a
+ | i2$a <= tmp
+ | module Inline1 :
+ | input a : UInt<32>
+ | output b : UInt<32>
+ | b <= a""".stripMargin
+ execute(input, check, Seq(flatten("Top")))
+ }
"The module instance i in Top " should "be inlined" in {
val input =