From aad8e09f355f4804d29361d75f54ce4a5c2d5c52 Mon Sep 17 00:00:00 2001 From: Adam Izraelevitz Date: Mon, 21 Nov 2016 09:12:59 -0800 Subject: Rewrote inline xform to fix quadratic perf. bug (#377) * Rewrote inline xform to fix quadratic perf. bug Turns out caching previously inlined modules is not useful The previous algorithm in a module, would flatten an instance's children, then flatten that instance. This caused all instances to be effectively inlined the number of times of its depth in the instance hierarchy, making it O(n*d*s), where n is the number of instances, and d is the depth of the instance, and s is the number of statements in the instance. The new algorithm directly inlines a module by keeping track of the parents of that instance, making it constant time with the number of instantiated instances. * Minor style fixes --- src/test/scala/firrtlTests/InlineInstancesTests.scala | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/InlineInstancesTests.scala b/src/test/scala/firrtlTests/InlineInstancesTests.scala index 36b007e8..92ed1195 100644 --- a/src/test/scala/firrtlTests/InlineInstancesTests.scala +++ b/src/test/scala/firrtlTests/InlineInstancesTests.scala @@ -49,11 +49,7 @@ class InlineInstancesTests extends LowTransformSpec { | wire i$b : UInt<32> | i$b <= i$a | b <= i$b - | i$a <= a - | module Inline : - | input a : UInt<32> - | output b : UInt<32> - | b <= a""".stripMargin + | i$a <= a""".stripMargin val writer = new StringWriter() val aMap = new AnnotationMap(Seq(InlineAnnotation(ModuleName("Inline", CircuitName("Top"))))) execute(writer, aMap, input, check) @@ -87,11 +83,7 @@ class InlineInstancesTests extends LowTransformSpec { | i1$b <= i1$a | b <= i1$b | i0$a <= a - | i1$a <= i0$b - | module Simple : - | input a : UInt<32> - | output b : UInt<32> - | b <= a""".stripMargin + | i1$a <= i0$b""".stripMargin val writer = new StringWriter() val aMap = new AnnotationMap(Seq(InlineAnnotation(ModuleName("Simple", CircuitName("Top"))))) execute(writer, aMap, input, check) @@ -166,10 +158,6 @@ class InlineInstancesTests extends LowTransformSpec { | b <= i1.b | i0$a <= a | i1.a <= i0$b - | module A : - | input a : UInt<32> - | output b : UInt<32> - | b <= a | module B : | input a : UInt<32> | output b : UInt<32> @@ -183,7 +171,6 @@ class InlineInstancesTests extends LowTransformSpec { execute(writer, aMap, input, check) } - // ---- Errors ---- // 1) ext module "External module" should "not be inlined" in { -- cgit v1.2.3