From: Michael Nolan Date: Sun, 9 Feb 2020 01:47:06 +0000 (-0500) Subject: Convert partsig to use the existing add_op function X-Git-Tag: ls180-24jan2020~226 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ba118cc6cdd54a231a4b0d8e1d2d086d8731f27;p=ieee754fpu.git Convert partsig to use the existing add_op function --- diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index 2c2da8a9..f71ecb4a 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -98,7 +98,7 @@ class PartitionedSignal: def __rrshift__(self, other): return Operator(">>", [other, self]) - def add_op(self, op1, op2): + def add_op(self, op1, op2, carry): op1 = getsig(op1) op2 = getsig(op2) shape = op1.shape() @@ -107,23 +107,13 @@ class PartitionedSignal: comb = self.m.d.comb comb += pa.a.eq(op1) comb += pa.b.eq(op2) - return pa.output + comb += pa.carry_in.eq(carry) + return (pa.output, pa.carry_out) def __add__(self, other): - return self.add_op(self, other) + result, _ =self.add_op(self, other, carry=0) + return result - def addc(self, other, carry): - shape = self.sig.shape() - pa = PartitionedAdder(shape[0], self.partpoints) - setattr(self.m.submodules, self.get_modname('add'), pa) - comb = self.m.d.comb - comb += pa.a.eq(self.sig) - comb += pa.carry_in.eq(carry) - if isinstance(other, PartitionedSignal): - comb += pa.b.eq(other.sig) - else: - comb += pa.b.eq(other) - return (pa.output, pa.carry_out) def __radd__(self, other): return self.add_op(other, self) diff --git a/src/ieee754/part/test/test_partsig.py b/src/ieee754/part/test/test_partsig.py index 5e5f310b..774e119f 100644 --- a/src/ieee754/part/test/test_partsig.py +++ b/src/ieee754/part/test/test_partsig.py @@ -57,7 +57,8 @@ class TestAddMod(Elaboratable): m.d.comb += self.gt_output.eq(self.a > self.b) m.d.comb += self.eq_output.eq(self.a == self.b) m.d.comb += self.ge_output.eq(self.a >= self.b) - add_out, add_carry = self.a.addc(self.b, self.carry_in) + add_out, add_carry = self.a.add_op(self.a, self.b, + self.carry_in) m.d.comb += self.add_output.eq(add_out) m.d.comb += self.carry_out.eq(add_carry) ppts = self.partpoints