From 4b44befef51dfc70f86b4ccea838aee1b9964463 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 28 Jun 2019 06:28:33 +0100 Subject: [PATCH] add cookie-cut fpdiv pipeline.py --- src/ieee754/fpdiv/pipeline.py | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/ieee754/fpdiv/pipeline.py diff --git a/src/ieee754/fpdiv/pipeline.py b/src/ieee754/fpdiv/pipeline.py new file mode 100644 index 00000000..b1a1f35c --- /dev/null +++ b/src/ieee754/fpdiv/pipeline.py @@ -0,0 +1,57 @@ +# IEEE Floating Point Adder (Single Precision) +# Copyright (C) Jonathan P Dawson 2013 +# 2013-12-12 + +from nmigen import Module +from nmigen.cli import main, verilog + +from nmutil.singlepipe import ControlBase +from nmutil.concurrentunit import ReservationStations, num_bits + +from ieee754.fpcommon.getop import FPADDBaseData +from ieee754.fpcommon.denorm import FPSCData +from ieee754.fpcommon.pack import FPPackData +from ieee754.fpcommon.normtopack import FPNormToPack +from .specialcases import FPDivSpecialCasesDeNorm +from .mulstages import FPDivStages + + + +class FPDIVBasePipe(ControlBase): + def __init__(self, width, id_wid): + ControlBase.__init__(self) + self.pipe1 = FPDivSpecialCasesDeNorm(width, id_wid) + self.pipe2 = FPDivStages(width, id_wid) + self.pipe3 = FPNormToPack(width, id_wid) + + self._eqs = self.connect([self.pipe1, self.pipe2, self.pipe3]) + + def elaborate(self, platform): + m = ControlBase.elaborate(self, platform) + m.submodules.scnorm = self.pipe1 + m.submodules.mulstages = self.pipe2 + m.submodules.normpack = self.pipe3 + m.d.comb += self._eqs + return m + + +class FPDIVMuxInOut(ReservationStations): + """ Reservation-Station version of FPDIV pipeline. + + * fan-in on inputs (an array of FPADDBaseData: a,b,mid) + * 2-stage multiplier pipeline + * fan-out on outputs (an array of FPPackData: z,mid) + + Fan-in and Fan-out are combinatorial. + """ + def __init__(self, width, num_rows): + self.width = width + self.id_wid = num_bits(width) + self.alu = FPDIVBasePipe(width, self.id_wid) + ReservationStations.__init__(self, num_rows) + + def i_specfn(self): + return FPADDBaseData(self.width, self.id_wid) + + def o_specfn(self): + return FPPackData(self.width, self.id_wid) -- 2.30.2