move groups test to top of loop
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 22 Aug 2019 01:08:39 +0000 (02:08 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 22 Aug 2019 01:08:39 +0000 (02:08 +0100)
src/ieee754/part_mul_add/multiply.py

index e2954e7609d21f200ecb1b25db81e0f9d8b9fe2e..93b1e22877e5998fc3134ee02f8c4d809b5c5617 100644 (file)
@@ -569,6 +569,9 @@ class AddReduce(Elaboratable):
         inputs = self.inputs
         ilen = len(inputs)
         while True:
+            groups = AddReduceSingle.full_adder_groups(len(inputs))
+            if len(groups) == 0:
+                break
             next_level = AddReduceSingle(ilen, self.output_width, n_parts,
                                          next_levels, partition_points)
             mods.append(next_level)
@@ -577,9 +580,6 @@ class AddReduce(Elaboratable):
             inputs = next_level.o.inputs
             ilen = len(inputs)
             part_ops = next_level.i.part_ops
-            next_groups = AddReduceSingle.full_adder_groups(len(inputs))
-            if len(next_groups) == 0:
-                break
 
         next_level = FinalAdd(ilen, self.output_width, n_parts,
                               next_levels, partition_points)