From 76dad8a6793d340e5d565a1c315685472d997772 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 23 Aug 2019 12:23:50 +0100 Subject: [PATCH] continue ispec/ospec on multiply --- src/ieee754/part_mul_add/multiply.py | 46 ++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/ieee754/part_mul_add/multiply.py b/src/ieee754/part_mul_add/multiply.py index e81e42a7..049ae0c8 100644 --- a/src/ieee754/part_mul_add/multiply.py +++ b/src/ieee754/part_mul_add/multiply.py @@ -347,9 +347,6 @@ class FinalAdd(Elaboratable): """ def __init__(self, n_inputs, output_width, n_parts, partition_points): - self.i = AddReduceData(partition_points, n_inputs, - output_width, n_parts) - self.o = FinalReduceData(partition_points, output_width, n_parts) self.output_width = output_width self.n_inputs = n_inputs self.n_parts = n_parts @@ -357,6 +354,17 @@ class FinalAdd(Elaboratable): if not self.partition_points.fits_in_width(output_width): raise ValueError("partition_points doesn't fit in output_width") + self.i = self.ispec() + self.o = self.ospec() + + def ispec(self): + return AddReduceData(self.partition_points, self.n_inputs, + self.output_width, self.n_parts) + + def ospec(self): + return FinalReduceData(self.partition_points, + self.output_width, self.n_parts) + def elaborate(self, platform): """Elaborate this module.""" m = Module() @@ -408,15 +416,23 @@ class AddReduceSingle(Elaboratable): self.n_inputs = n_inputs self.n_parts = n_parts self.output_width = output_width - self.i = AddReduceData(partition_points, n_inputs, - output_width, n_parts) self.partition_points = PartitionPoints(partition_points) if not self.partition_points.fits_in_width(output_width): raise ValueError("partition_points doesn't fit in output_width") self.groups = AddReduceSingle.full_adder_groups(n_inputs) - n_terms = AddReduceSingle.calc_n_inputs(n_inputs, self.groups) - self.o = AddReduceData(partition_points, n_terms, output_width, n_parts) + self.n_terms = AddReduceSingle.calc_n_inputs(n_inputs, self.groups) + + self.i = self.ispec() + self.o = self.ospec() + + def ispec(self): + return AddReduceData(self.partition_points, self.n_inputs, + self.output_width, self.n_parts) + + def ospec(self): + return AddReduceData(self.partition_points, self.n_terms, + self.output_width, self.n_parts) @staticmethod def calc_n_inputs(n_inputs, groups): @@ -1270,9 +1286,19 @@ class Intermediates(Elaboratable): """ Intermediate output modules """ - def __init__(self, output_width, n_parts, partition_points): - self.i = FinalReduceData(partition_points, output_width, n_parts) - self.o = IntermediateData(partition_points, output_width, n_parts) + def __init__(self, output_width, n_parts, part_pts): + self.part_pts = part_pts + self.output_width = output_width + self.n_parts = n_parts + + self.i = self.ispec() + self.o = self.ospec() + + def ispec(self): + return FinalReduceData(self.part_pts, self.output_width, self.n_parts) + + def ospec(self): + return IntermediateData(self.part_pts, self.output_width, self.n_parts) def elaborate(self, platform): m = Module() -- 2.30.2