exclude stuff that is just multiplying by zero
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 7 Jul 2019 16:08:20 +0000 (17:08 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 7 Jul 2019 16:08:20 +0000 (17:08 +0100)
src/ieee754/div_rem_sqrt_rsqrt/core.py

index f87077df4e7adaede929c9ed331053b29cddcbc2..0f76d7125fbe80a7b133ba290dc40ba35e17298d 100644 (file)
@@ -309,20 +309,23 @@ class DivPipeCoreCalculateStage(Elaboratable):
 
             # UDivRem
             div_rhs = self.i.compare_rhs
-            div_factor1 = self.i.divisor_radicand * shifted_trial_bits2
-            div_rhs += div_factor1 << self.core_config.fract_width
+            if tb != 0: # no point adding stuff that's multiplied by zero
+                div_factor1 = self.i.divisor_radicand * shifted_trial_bits2
+                div_rhs += div_factor1 << self.core_config.fract_width
 
             # SqrtRem
             sqrt_rhs = self.i.compare_rhs
-            sqrt_factor1 = self.i.quotient_root * shifted_trial_bits2
-            sqrt_rhs += sqrt_factor1 << self.core_config.fract_width
-            sqrt_factor2 = shifted_trial_bits_sqrd
-            sqrt_rhs += sqrt_factor2 << self.core_config.fract_width
+            if tb != 0: # no point adding stuff that's multiplied by zero
+                sqrt_factor1 = self.i.quotient_root * shifted_trial_bits2
+                sqrt_rhs += sqrt_factor1 << self.core_config.fract_width
+                sqrt_factor2 = shifted_trial_bits_sqrd
+                sqrt_rhs += sqrt_factor2 << self.core_config.fract_width
 
             # RSqrtRem
             rsqrt_rhs = self.i.compare_rhs
-            rsqrt_rhs += self.i.root_times_radicand * shifted_trial_bits2
-            rsqrt_rhs += self.i.divisor_radicand * shifted_trial_bits_sqrd
+            if tb != 0: # no point adding stuff that's multiplied by zero
+                rsqrt_rhs += self.i.root_times_radicand * shifted_trial_bits2
+                rsqrt_rhs += self.i.divisor_radicand * shifted_trial_bits_sqrd
 
             trial_compare_rhs = Signal.like(
                 self.o.compare_rhs, name=f"trial_compare_rhs_{trial_bits}")