cut top trial comparison
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Jul 2020 04:26:17 +0000 (05:26 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Jul 2020 04:26:17 +0000 (05:26 +0100)
src/ieee754/div_rem_sqrt_rsqrt/core.py

index d79c73a163e6502759c0b13f3773d1454d508b31..d6727dc001c67337ef08fd1d11b67e24c05e37e0 100644 (file)
@@ -419,7 +419,12 @@ class DivPipeCoreCalculateStage(Elaboratable):
             # make the trial comparison against the [invariant] lhs.
             # trial_compare_rhs is always decreasing as trial_bits increases
             pass_flag = Signal(name=f"pass_flag_{trial_bits}", reset_less=True)
-            comb += pass_flag.eq(self.i.compare_lhs >= t.trial_compare_rhs)
+            if trial_bits == radix-1:
+                # do not do last comparison: no point.  if all others
+                # fail we pick this one anyway.
+                comb += pass_flag.eq(0)
+            else:
+                comb += pass_flag.eq(self.i.compare_lhs >= t.trial_compare_rhs)
             pfl.append(pass_flag)
 
         # Cat all the pass flags list together (easier to handle, below)
@@ -448,7 +453,9 @@ class DivPipeCoreCalculateStage(Elaboratable):
         tcrh = trial_compare_rhs_values
         bw = self.core_config.bit_width
         for i in range(radix):
-            crhs.append(Repl(next_bits == i, bw*3) & tcrh[i])
+            nbe = Signal(reset_less=True)
+            comb += nbe.eq(next_bits == i)
+            crhs.append(Repl(nbe, bw*3) & tcrh[i])
         comb += self.o.compare_rhs.eq(treereduce(crhs, operator.or_,
                                       lambda x:x))