# See Notices.txt for copyright information
""" div/rem/sqrt/rsqrt pipeline. """
+from nmigen import Signal
from ieee754.div_rem_sqrt_rsqrt.core import (DivPipeCoreConfig,
DivPipeCoreInputData,
DivPipeCoreInterstageData,
from ieee754.fpcommon.fpbase import FPFormat, FPNumBaseRecord
-class DivPipeConfig:
- """ Configuration for the div/rem/sqrt/rsqrt pipeline.
-
- :attribute pspec: ``PipelineSpec`` instance
- :attribute core_config: the ``DivPipeCoreConfig`` instance.
- """
-
- def __init__(self, pspec, log2_radix=3):
- """ Create a ``DivPipeConfig`` instance. """
- self.pspec = pspec
- bit_width = pspec.width
- fract_width = FPFormat.standard(bit_width).fraction_width
- self.core_config = DivPipeCoreConfig(bit_width,
- fract_width,
- log2_radix)
-
-
class DivPipeBaseData:
""" input data base type for ``DivPipe``.
:attribute config: the ``DivPipeConfig`` instance.
"""
- def __init__(self, config):
+ def __init__(self, pspec):
""" Create a ``DivPipeBaseData`` instance. """
- self.config = config
- width = config.pspec.width
+ self.pspec = pspec
+ width = pspec.width
self.z = FPNumBaseRecord(width, False) # s and e carried: m ignored
self.out_do_z = Signal(reset_less=True)
self.oz = Signal(width, reset_less=True)
- self.ctx = FPPipeContext(config.pspec) # context: muxid, operator etc.
+ self.ctx = FPPipeContext(pspec) # context: muxid, operator etc.
# FIXME: add proper muxid explanation somewhere and refer to it here
self.muxid = self.ctx.muxid # annoying. complicated.
def eq(self, rhs):
""" Assign member signals. """
- return [self.z.eq(rhs.z), self.out_do_z.eq(i.out_do_z), self.oz.eq(i.oz),
- self.ctx.eq(i.ctx)]
+ return [self.z.eq(rhs.z), self.out_do_z.eq(rhs.out_do_z),
+ self.oz.eq(rhs.oz), self.ctx.eq(rhs.ctx)]
class DivPipeInputData(DivPipeCoreInputData, DivPipeBaseData):
""" input data type for ``DivPipe``. """
- def __init__(self, config):
+ def __init__(self, pspec):
""" Create a ``DivPipeInputData`` instance. """
- DivPipeCoreInputData.__init__(self, config.core_config)
- DivPipeBaseData.__init__(self, config)
+ DivPipeCoreInputData.__init__(self, pspec.core_config)
+ DivPipeBaseData.__init__(self, pspec)
def __iter__(self):
""" Get member signals. """
class DivPipeInterstageData(DivPipeCoreInterstageData, DivPipeBaseData):
""" interstage data type for ``DivPipe``. """
- def __init__(self, config):
+ def __init__(self, pspec):
""" Create a ``DivPipeInterstageData`` instance. """
- DivPipeCoreInterstageData.__init__(self, config.core_config)
- DivPipeBaseData.__init__(self, config)
+ DivPipeCoreInterstageData.__init__(self, pspec.core_config)
+ DivPipeBaseData.__init__(self, pspec)
def __iter__(self):
""" Get member signals. """
class DivPipeOutputData(DivPipeCoreOutputData, DivPipeBaseData):
""" output data type for ``DivPipe``. """
- def __init__(self, config):
+ def __init__(self, pspec):
""" Create a ``DivPipeOutputData`` instance. """
- DivPipeCoreOutputData.__init__(self, config.core_config)
- DivPipeBaseData.__init__(self, config)
+ DivPipeCoreOutputData.__init__(self, pspec.core_config)
+ DivPipeBaseData.__init__(self, pspec)
def __iter__(self):
""" Get member signals. """
FPDivStagesIntermediate,
FPDivStagesFinal)
from ieee754.pipeline import PipelineSpec
+from ieee754.div_rem_sqrt_rsqrt.core import DivPipeCoreConfig
class FPDIVBasePipe(ControlBase):
self.pipechain = pipechain
# start and end: unpack/specialcases then normalisation/packing
- self.pipestart = FPDIVSpecialCasesDeNorm(self.pspec)
- self.pipeend = FPNormToPack(self.pspec)
+ self.pipestart = pipestart = FPDIVSpecialCasesDeNorm(self.pspec)
+ self.pipeend = pipeend = FPNormToPack(self.pspec)
self._eqs = self.connect([pipestart] + pipechain + [pipeend])
self.pspec = PipelineSpec(width, self.id_wid, op_wid)
# get the standard mantissa width, store in the pspec
# (used in DivPipeBaseStage.get_core_config)
- p = FPFormat.standard(width)
- self.pspec.m_width = p.m_width
+ fpformat = FPFormat.standard(width)
+ log2_radix = 2
+ cfg = DivPipeCoreConfig(width, fpformat.fraction_width, log2_radix)
+ self.pspec.fpformat = fpformat
+ self.pspec.log2_radix = log2_radix
+ self.pspec.core_config = cfg
# XXX TODO - a class (or function?) that takes the pspec (right here)
# and creates... "something". that "something" MUST have an eq function