From: Luke Kenneth Casson Leighton Date: Fri, 3 Jul 2020 03:45:04 +0000 (+0100) Subject: remove use of Array, replace with treereduce X-Git-Tag: ls180-24jan2020~51 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36547eb345d6582fdb264c8e1766720d4a4e4ac0;p=ieee754fpu.git remove use of Array, replace with treereduce --- diff --git a/src/ieee754/div_rem_sqrt_rsqrt/core.py b/src/ieee754/div_rem_sqrt_rsqrt/core.py index 603af40a..d79c73a1 100644 --- a/src/ieee754/div_rem_sqrt_rsqrt/core.py +++ b/src/ieee754/div_rem_sqrt_rsqrt/core.py @@ -18,9 +18,11 @@ Formulas solved are: The remainder is the left-hand-side of the comparison minus the right-hand-side of the comparison in the above formulas. """ -from nmigen import (Elaboratable, Module, Signal, Const, Mux, Cat, Array) +from nmigen import (Elaboratable, Module, Signal, Const, Mux, Cat, Repl) from nmigen.lib.coding import PriorityEncoder +from nmutil.util import treereduce import enum +import operator class DivPipeCoreOperation(enum.Enum): @@ -440,9 +442,15 @@ class DivPipeCoreCalculateStage(Elaboratable): with m.Else(): comb += next_bits.eq(radix-1) - # get the highest passing rhs trial (indexed by next_bits) - ta = Array(trial_compare_rhs_values) - comb += self.o.compare_rhs.eq(ta[next_bits]) + # get the highest passing rhs trial. use treereduce because + # Array on such massively long numbers is insanely gate-hungry + crhs = [] + 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]) + comb += self.o.compare_rhs.eq(treereduce(crhs, operator.or_, + lambda x:x)) # create outputs for next phase qr = self.i.quotient_root | (next_bits << current_shift)