From 9ba118cc6cdd54a231a4b0d8e1d2d086d8731f27 Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Sat, 8 Feb 2020 20:47:06 -0500 Subject: [PATCH] Convert partsig to use the existing add_op function --- src/ieee754/part/partsig.py | 20 +++++--------------- src/ieee754/part/test/test_partsig.py | 3 ++- 2 files changed, 7 insertions(+), 16 deletions(-) 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 -- 2.30.2