From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 11:48:35 +0000 (+0100) Subject: tidyup X-Git-Tag: ls180-24jan2020~637 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09903d463568b401d2f68c86f1d496b97a0c6747;p=ieee754fpu.git tidyup --- diff --git a/src/ieee754/fpcommon/corrections.py b/src/ieee754/fpcommon/corrections.py index 18a08a04..df7d97f5 100644 --- a/src/ieee754/fpcommon/corrections.py +++ b/src/ieee754/fpcommon/corrections.py @@ -2,18 +2,18 @@ # Copyright (C) Jonathan P Dawson 2013 # 2013-12-12 -from nmigen import Module, Elaboratable +from nmigen import Module from nmigen.cli import main, verilog -from ieee754.fpcommon.fpbase import FPState, FPNumBase -from .roundz import FPRoundData +from ieee754.fpcommon.modbase import FPModBase +from ieee754.fpcommon.fpbase import FPNumBase +from ieee754.fpcommon.roundz import FPRoundData -class FPCorrectionsMod(Elaboratable): + +class FPCorrectionsMod(FPModBase): def __init__(self, pspec): - self.pspec = pspec - self.i = self.ispec() - self.out_z = self.ospec() + super().__init__(pspec, "corrections") def ispec(self): return FPRoundData(self.pspec) @@ -21,48 +21,13 @@ class FPCorrectionsMod(Elaboratable): def ospec(self): return FPRoundData(self.pspec) - def process(self, i): - return self.out_z - - def setup(self, m, i): - """ links module to inputs and outputs - """ - m.submodules.corrections = self - m.d.comb += self.i.eq(i) - def elaborate(self, platform): m = Module() m.submodules.corr_in_z = in_z = FPNumBase(self.i.z) - #m.submodules.corr_out_z = self.out_z.z - m.d.comb += self.out_z.eq(self.i) # copies mid, z, out_do_z + m.d.comb += self.o.eq(self.i) # copies mid, z, out_do_z with m.If(~self.i.out_do_z): with m.If(in_z.is_denormalised): - m.d.comb += self.out_z.z.e.eq(self.i.z.N127) + m.d.comb += self.o.z.e.eq(self.i.z.N127) return m -class FPCorrections(FPState): - - def __init__(self, width, id_wid): - FPState.__init__(self, "corrections") - self.mod = FPCorrectionsMod(width) - self.out_z = self.ospec() - - def ispec(self): - return self.mod.ispec() - - def ospec(self): - return self.mod.ospec() - - def setup(self, m, in_z): - """ links module to inputs and outputs - """ - self.mod.setup(m, in_z) - - m.d.sync += self.out_z.eq(self.mod.out_z) - m.d.sync += self.out_z.ctx.eq(self.mod.o.ctx) - - def action(self, m): - m.next = "pack" - -