from nmigen import Module, Signal, Cat
from nmutil.pipemodbase import PipeModBase
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.pack import FPPackData
from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord
super().__init__(in_pspec, "fclass")
def ispec(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def ospec(self):
return FPPackData(self.out_pspec)
from nmutil.singlepipe import ControlBase
from nmutil.concurrentunit import ReservationStations, num_bits
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.pack import FPPackData
class FPClassMuxInOutBase(ReservationStations):
""" Reservation-Station version of FPClass pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 2-stage multiplier pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def o_specfn(self):
return FPPackData(self.out_pspec)
class FPClassMuxInOut(FPClassMuxInOutBase):
""" Reservation-Station version of FPClass pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 2-stage multiplier pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
from nmigen.cli import main, verilog
from nmutil.pipemodbase import PipeModBase
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.postcalc import FPPostCalcData
from ieee754.fpcommon.msbhigh import FPMSBHigh
from ieee754.fpcommon.exphigh import FPEXPHigh
super().__init__(in_pspec, "downconvert")
def ispec(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def ospec(self):
return FPPostCalcData(self.out_pspec, e_extra=True)
from nmigen.cli import main, verilog
from ieee754.fpcommon.fpbase import Overflow
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.postcalc import FPPostCalcData
from ieee754.fpcommon.exphigh import FPEXPHigh
self.o = self.ospec()
def ispec(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def ospec(self):
return FPPackData(self.out_pspec)
from nmigen.cli import main, verilog
from nmutil.pipemodbase import PipeModBase
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.postcalc import FPPostCalcData
from ieee754.fpcommon.msbhigh import FPMSBHigh
super().__init__(in_pspec, "intconvert")
def ispec(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def ospec(self):
return FPPostCalcData(self.out_pspec, e_extra=True)
from nmutil.singlepipe import ControlBase
from nmutil.concurrentunit import ReservationStations, num_bits
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.pack import FPPackData
from ieee754.fpcommon.normtopack import FPNormToPack
class FPCVTMuxInOutBase(ReservationStations):
""" Reservation-Station version of FPCVT pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 2-stage multiplier pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def o_specfn(self):
return FPPackData(self.out_pspec)
class FPCVTF2IntMuxInOut(FPCVTMuxInOutBase):
""" Reservation-Station version of FPCVT pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 2-stage multiplier pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
from nmigen.cli import main, verilog
from nmutil.pipemodbase import PipeModBase
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.postcalc import FPPostCalcData
from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord
super().__init__(in_pspec, "upconvert")
def ispec(self):
- return FPADDBaseData(self.in_pspec)
+ return FPBaseData(self.in_pspec)
def ospec(self):
return FPPostCalcData(self.out_pspec, e_extra=False)
* addalign - FPAddAlignSingleAdd
* normpack - FPNormToPack
-scnorm - FPDIVSpecialCasesDeNorm ispec FPADDBaseData
+scnorm - FPDIVSpecialCasesDeNorm ispec FPBaseData
------ ospec FPSCData
StageChain: FPMULSpecialCasesMod,
from nmutil.multipipe import PriorityCombMuxInPipe
from nmutil.concurrentunit import ReservationStations, num_bits
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import FPSCData
from ieee754.fpcommon.pack import FPPackData
from ieee754.fpcommon.normtopack import FPNormToPack
class FPADDMuxInOut(ReservationStations):
""" Reservation-Station version of FPADD pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 3-stage adder pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def o_specfn(self):
return FPPackData(self.pspec)
from ieee754.fpcommon.fpbase import FPNumDecode
from ieee754.fpcommon.fpbase import FPNumBaseRecord
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod)
super().__init__(pspec, "specialcases")
def ispec(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def ospec(self):
return FPSCData(self.pspec, True)
from nmutil.singlepipe import StageChain
from ieee754.fpcommon.fpbase import FPState, FPID
-from ieee754.fpcommon.getop import (FPGetOp, FPADDBaseData, FPGet2Op)
+from ieee754.fpcommon.getop import (FPGetOp, FPBaseData, FPGet2Op)
from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNorm)
from ieee754.fpcommon.postcalc import FPPostCalcData
from ieee754.fpcommon.postnormalise import (FPNorm1Data,
self.states = []
def ispec(self):
- return FPADDBaseData(self.width, self.id_wid)
+ return FPBaseData(self.width, self.id_wid)
def ospec(self):
return FPOpData(self.width, self.id_wid)
--- /dev/null
+# IEEE Floating Point Adder (Single Precision)
+# Copyright (C) 2019 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+
+from nmigen import Signal
+from ieee754.fpcommon.getop import FPPipeContext
+
+
+class FPBaseData:
+
+ def __init__(self, pspec, n_ops=2):
+ width = pspec.width
+ self.ctx = FPPipeContext(pspec)
+ ops = []
+ for i in range(n_ops):
+ name = chr(ord("a")+i)
+ operand = Signal(width, name=name)
+ setattr(self, name, operand)
+ ops.append(operand)
+ self.muxid = self.ctx.muxid # make muxid available here: complicated
+ self.ops = ops
+
+ def eq(self, i):
+ ret = []
+ for op1, op2 in zip(self.ops, i.ops):
+ ret.append(op1.eq(op2))
+ ret.append(self.ctx.eq(i.ctx))
+ return ret
+
+ def __iter__(self):
+ if self.ops:
+ yield from self.ops
+ yield from self.ctx
+
+ def ports(self):
+ return list(self)
+
+
return list(self)
-class FPADDBaseData:
-
- def __init__(self, pspec, n_ops=2):
- width = pspec.width
- self.ctx = FPPipeContext(pspec)
- ops = []
- for i in range(n_ops):
- name = chr(ord("a")+i)
- operand = Signal(width, name=name)
- setattr(self, name, operand)
- ops.append(operand)
- self.muxid = self.ctx.muxid # make muxid available here: complicated
- self.ops = ops
-
- def eq(self, i):
- ret = []
- for op1, op2 in zip(self.ops, i.ops):
- ret.append(op1.eq(op2))
- ret.append(self.ctx.eq(i.ctx))
- return ret
-
- def __iter__(self):
- if self.ops:
- yield from self.ops
- yield from self.ctx
-
- def ports(self):
- return list(self)
-
-
class FPGet2OpMod(PrevControl):
def __init__(self, width, id_wid, op_wid=None):
PrevControl.__init__(self)
self.o = self.ospec()
def ispec(self):
- return FPADDBaseData(self.width, self.id_wid, self.op_wid)
+ return FPBaseData(self.width, self.id_wid, self.op_wid)
def ospec(self):
- return FPADDBaseData(self.width, self.id_wid, self.op_wid)
+ return FPBaseData(self.width, self.id_wid, self.op_wid)
def process(self, i):
return self.o
Stack looks like this:
-scnorm - FPDIVSpecialCasesDeNorm ispec FPADDBaseData
+scnorm - FPDIVSpecialCasesDeNorm ispec FPBaseData
------ ospec FPSCData
StageChain: FPDIVSpecialCasesMod,
from nmutil.singlepipe import ControlBase
from nmutil.concurrentunit import ReservationStations, num_bits
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import FPSCData
from ieee754.fpcommon.fpbase import FPFormat
from ieee754.fpcommon.pack import FPPackData
class FPDIVMuxInOut(ReservationStations):
""" Reservation-Station version of FPDIV pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* N-stage divider pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def o_specfn(self):
return FPPackData(self.pspec)
from nmutil.pipemodbase import PipeModBase, PipeModBaseChain
from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod)
from ieee754.fpmul.align import FPAlignModSingle
from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreOperation as DP
super().__init__(pspec, "specialcases")
def ispec(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def ospec(self):
return FPSCData(self.pspec, False)
* mulstages - FPMulstages
* normpack - FPNormToPack
-scnorm - FPDIVSpecialCasesDeNorm ispec FPADDBaseData
+scnorm - FPDIVSpecialCasesDeNorm ispec FPBaseData
------ ospec FPSCData
StageChain: FPMULSpecialCasesMod,
from nmutil.singlepipe import ControlBase
from nmutil.concurrentunit import ReservationStations, num_bits
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import FPSCData
from ieee754.fpcommon.pack import FPPackData
from ieee754.fpcommon.normtopack import FPNormToPack
class FPMULMuxInOut(ReservationStations):
""" Reservation-Station version of FPMUL pipeline.
- * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
+ * fan-in on inputs (an array of FPBaseData: a,b,mid)
* 2-stage multiplier pipeline
* fan-out on outputs (an array of FPPackData: z,mid)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def o_specfn(self):
return FPPackData(self.pspec)
from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord
from nmutil.pipemodbase import PipeModBase, PipeModBaseChain
-from ieee754.fpcommon.getop import FPADDBaseData
+from ieee754.fpcommon.basedata import FPBaseData
from ieee754.fpcommon.denorm import (FPSCData, FPAddDeNormMod)
from ieee754.fpmul.align import FPAlignModSingle
super().__init__(pspec, "specialcases")
def ispec(self):
- return FPADDBaseData(self.pspec)
+ return FPBaseData(self.pspec)
def ospec(self):
return FPSCData(self.pspec, False)