From e03e3f730250673ffa48c000caa369ed582467a2 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Thu, 24 May 2018 15:18:58 -0700 Subject: Use Vec.apply instead of new Vec in VecInit.apply (#825) The Vec constructor invokes the gen argument for each element in the Vec. Since VecInit invokes cloneSupertype which touches every element of the input Seq, this was an n^2 operation. Vec.apply accepts its arguments by value so cloneSupertype is only called once. It then calls cloneType on that once for each element in the Vec, which is constant time reducing the overall complexity of VecInit to just n.--- chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chiselFrontend/src/main') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala index 18ab8dc2..35d2c0f6 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala @@ -277,7 +277,7 @@ object VecInit { require(!elts.isEmpty) elts.foreach(requireIsHardware(_, "vec element")) - val vec = Wire(new Vec(cloneSupertype(elts, "Vec"), elts.length)) + val vec = Wire(Vec(elts.length, cloneSupertype(elts, "Vec"))) // TODO: try to remove the logic for this mess elts.head.direction match { -- cgit v1.2.3