-# IEEE Floating Point Adder (Single Precision)
-# Copyright (C) Jonathan P Dawson 2013
-# 2013-12-12
+"""IEEE754 Floating Point Adder Pipeline
+
+Copyright (C) 2019 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+
+"""
from nmigen import Module
from nmigen.cli import main, verilog
class FPAddAlignSingleAdd(DynamicPipe):
def __init__(self, pspec):
- #FPState.__init__(self, "align")
self.pspec = pspec
super().__init__(pspec)
-# IEEE Floating Point Muler (Single Precision)
-# Copyright (C) Jonathan P Dawson 2013
-# 2013-12-12
+"""IEEE754 Floating Point Multiplier Pipeline
+
+Copyright (C) 2019 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+
+"""
from nmigen import Module, Signal, Cat, Elaboratable
from nmigen.cli import main, verilog
from ieee754.fpcommon.fpbase import FPNumBaseRecord
-from ieee754.fpcommon.fpbase import FPState
from ieee754.fpcommon.denorm import FPSCData
from ieee754.fpcommon.getop import FPPipeContext
def elaborate(self, platform):
m = Module()
- #m.submodules.mul0_in_a = self.i.a
- #m.submodules.mul0_in_b = self.i.b
- #m.submodules.mul0_out_z = self.o.z
# store intermediate tests (and zero-extended mantissas)
am0 = Signal(len(self.i.a.m)+1, reset_less=True)
m.d.comb += self.o.out_do_z.eq(self.i.out_do_z)
m.d.comb += self.o.ctx.eq(self.i.ctx)
return m
-
-
-class FPMulStage0(FPState):
- """ First stage of mul.
- """
-
- def __init__(self, width, id_wid):
- FPState.__init__(self, "multiply_0")
- self.mod = FPMulStage0Mod(width)
- self.o = self.mod.ospec()
-
- def setup(self, m, i):
- """ links module to inputs and outputs
- """
- self.mod.setup(m, i)
-
- # NOTE: these could be done as combinatorial (merge mul0+mul1)
- m.d.sync += self.o.eq(self.mod.o)
-
- def action(self, m):
- m.next = "multiply_1"
-# IEEE Floating Point Multiplier
+"""IEEE754 Floating Point Multiplier Pipeline
+
+Copyright (C) 2019 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+
+"""
from nmigen import Module, Signal, Elaboratable
from nmigen.cli import main, verilog
-from ieee754.fpcommon.fpbase import FPState
from ieee754.fpcommon.postcalc import FPAddStage1Data
-from .mul0 import FPMulStage0Data
+from ieee754.fpmul.mul0 import FPMulStage0Data
-class FPMulStage1Mod(FPState, Elaboratable):
+class FPMulStage1Mod(Elaboratable):
""" Second stage of mul: preparation for normalisation.
"""
m.d.comb += self.o.ctx.eq(self.i.ctx)
return m
-
-
-class FPMulStage1(FPState):
-
- def __init__(self, pspec):
- FPState.__init__(self, "multiply_1")
- width = pspec.width
- self.mod = FPMulStage1Mod(pspec)
- self.out_z = FPNumBaseRecord(width, False)
- self.norm_stb = Signal()
-
- def setup(self, m, i):
- """ links module to inputs and outputs
- """
- self.mod.setup(m, i)
-
- m.d.sync += self.norm_stb.eq(0) # sets to zero when not in mul1 state
-
- m.d.sync += self.out_z.eq(self.mod.out_z)
- m.d.sync += self.norm_stb.eq(1)
-
- def action(self, m):
- m.next = "normalise_1"
-