tidyup, use FPModBaseChain and FPModBase
[ieee754fpu.git] / src / ieee754 / fcvt / int2float.py
index 8d45513b110453777192e01b18570d7ea66a4289..889c301c5788a403a73542c1f6448497f754255f 100644 (file)
@@ -1,9 +1,10 @@
 # IEEE Floating Point Conversion
 # Copyright (C) 2019 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
 
-from nmigen import Module, Signal, Cat, Const, Mux, Elaboratable
+from nmigen import Module, Signal, Cat
 from nmigen.cli import main, verilog
 
+from ieee754.fpcommon.modbase import FPModBase
 from ieee754.fpcommon.getop import FPADDBaseData
 from ieee754.fpcommon.postcalc import FPAddStage1Data
 from ieee754.fpcommon.msbhigh import FPMSBHigh
@@ -11,7 +12,7 @@ from ieee754.fpcommon.msbhigh import FPMSBHigh
 from ieee754.fpcommon.fpbase import FPNumDecode, FPNumBaseRecord
 
 
-class FPCVTIntToFloatMod(Elaboratable):
+class FPCVTIntToFloatMod(FPModBase):
     """ FP integer conversion: copes with 16/32/64 int to 16/32/64 fp.
 
         self.ctx.i.op & 0x1 == 0x1 : SIGNED int
@@ -20,8 +21,7 @@ class FPCVTIntToFloatMod(Elaboratable):
     def __init__(self, in_pspec, out_pspec):
         self.in_pspec = in_pspec
         self.out_pspec = out_pspec
-        self.i = self.ispec()
-        self.o = self.ospec()
+        super().__init__(in_pspec, "intconvert")
 
     def ispec(self):
         return FPADDBaseData(self.in_pspec)
@@ -29,15 +29,6 @@ class FPCVTIntToFloatMod(Elaboratable):
     def ospec(self):
         return FPAddStage1Data(self.out_pspec, e_extra=True)
 
-    def setup(self, m, i):
-        """ links module to inputs and outputs
-        """
-        m.submodules.intconvert = self
-        m.d.comb += self.i.eq(i)
-
-    def process(self, i):
-        return self.o
-
     def elaborate(self, platform):
         m = Module()
         comb = m.d.comb