X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fieee754%2Fpart_mul_add%2Fmultiply.py;h=89e4c4d322782ff1e16b2e88646405d6dcce0bd3;hb=31409cddf82e9d34ee6d25d89911bda28719afe8;hp=41506f69d905ca9e08b252e48d83456c8b6d39a8;hpb=5d420f828ddecb499195119246aafe2f2c56700d;p=ieee754fpu.git diff --git a/src/ieee754/part_mul_add/multiply.py b/src/ieee754/part_mul_add/multiply.py index 41506f69..89e4c4d3 100644 --- a/src/ieee754/part_mul_add/multiply.py +++ b/src/ieee754/part_mul_add/multiply.py @@ -310,7 +310,7 @@ class AddReduceData: def __init__(self, part_pts, n_inputs, output_width, n_parts): self.part_ops = [Signal(2, name=f"part_ops_{i}", reset_less=True) for i in range(n_parts)] - self.terms = [Signal(output_width, name=f"inputs_{i}", + self.terms = [Signal(output_width, name=f"terms_{i}", reset_less=True) for i in range(n_inputs)] self.part_pts = part_pts.like() @@ -539,7 +539,7 @@ class AddReduceSingle(PipeModBase): class AddReduceInternal: - """Recursively Add list of numbers together. + """Iteratively Add list of numbers together. :attribute inputs: input ``Signal``s to be summed. Modification not supported, except for by ``Signal.eq``. @@ -550,19 +550,17 @@ class AddReduceInternal: supported, except for by ``Signal.eq``. """ - def __init__(self, i, pspec, partition_step=1): + def __init__(self, pspec, n_inputs, part_pts, partition_step=1): """Create an ``AddReduce``. :param inputs: input ``Signal``s to be summed. :param output_width: bit-width of ``output``. :param partition_points: the input partition points. """ - self.i = i self.pspec = pspec - self.inputs = i.terms - self.part_ops = i.part_ops + self.n_inputs = n_inputs self.output_width = pspec.width * 2 - self.partition_points = i.part_pts + self.partition_points = part_pts self.partition_step = partition_step self.create_levels() @@ -572,12 +570,9 @@ class AddReduceInternal: mods = [] partition_points = self.partition_points - part_ops = self.part_ops - n_parts = len(part_ops) - inputs = self.inputs - ilen = len(inputs) + ilen = self.n_inputs while True: - groups = AddReduceSingle.full_adder_groups(len(inputs)) + groups = AddReduceSingle.full_adder_groups(ilen) if len(groups) == 0: break lidx = len(mods) @@ -586,9 +581,7 @@ class AddReduceInternal: self.partition_step) mods.append(next_level) partition_points = next_level.i.part_pts - inputs = next_level.o.terms - ilen = len(inputs) - part_ops = next_level.i.part_ops + ilen = len(next_level.o.terms) lidx = len(mods) next_level = FinalAdd(self.pspec, lidx, ilen, @@ -626,7 +619,8 @@ class AddReduce(AddReduceInternal, Elaboratable): n_parts = len(part_ops) self.i = AddReduceData(part_pts, len(inputs), output_width, n_parts) - AddReduceInternal.__init__(self, self.i, output_width, partition_step) + AddReduceInternal.__init__(self, pspec, n_inputs, part_pts, + partition_step) self.o = FinalReduceData(part_pts, output_width, n_parts) self.register_levels = register_levels @@ -1380,17 +1374,15 @@ class Mul8_16_32_64(Elaboratable): part_pts = self.part_pts - n_parts = self.pspec.n_parts n_inputs = 64 + 4 - output_width = self.pspec.width * 2 t = AllTerms(self.pspec, n_inputs) t.setup(m, self.i) terms = t.o.terms - at = AddReduceInternal(t.process(self.i), self.pspec, partition_step=2) + at = AddReduceInternal(self.pspec, n_inputs, part_pts, partition_step=2) - i = at.i + i = t.o for idx in range(len(at.levels)): mcur = at.levels[idx] mcur.setup(m, i)