From 55cb58877aca898f1ccae5edf29aeede9d1b71ba Mon Sep 17 00:00:00 2001 From: Øyvind Harboe Date: Sat, 11 Dec 2021 04:39:27 +0100 Subject: reduceTree() now operates on Seq (#2292) preserves input/output information of the type being reduced. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>--- core/src/main/scala/chisel3/Aggregate.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/src/main/scala') diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala index dbde7068..600e2d11 100644 --- a/core/src/main/scala/chisel3/Aggregate.scala +++ b/core/src/main/scala/chisel3/Aggregate.scala @@ -338,11 +338,11 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) def do_reduceTree(redOp: (T, T) => T, layerOp: (T) => T = (x: T) => x) (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : T = { require(!isEmpty, "Cannot apply reduction on a vec of size 0") - var curLayer = this + var curLayer : Seq[T] = this while (curLayer.length > 1) { - curLayer = VecInit(curLayer.grouped(2).map( x => + curLayer = curLayer.grouped(2).map( x => if (x.length == 1) layerOp(x(0)) else redOp(x(0), x(1)) - ).toSeq) + ).toSeq } curLayer(0) } -- cgit v1.2.3