move FPPackData to separate module
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 31 Jul 2019 21:32:56 +0000 (22:32 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 31 Jul 2019 21:32:56 +0000 (22:32 +0100)
src/ieee754/fpcommon/pack.py
src/ieee754/fpcommon/packdata.py [new file with mode: 0644]

index 4f906bd332fbab3ba97746cdbfb01bfca0bdafe0..d53533b1ef3d747c8d63d33d5943669cadf0acb6 100644 (file)
@@ -9,33 +9,7 @@ from nmutil.pipemodbase import PipeModBase
 from ieee754.fpcommon.fpbase import FPNumBaseRecord, FPNumBase
 from ieee754.fpcommon.roundz import FPRoundData
 from ieee754.fpcommon.getop import FPPipeContext
-
-
-class FPPackData:
-
-    def __init__(self, pspec):
-        width = pspec.width
-        self.z = Signal(width, reset_less=True)    # result
-        self.ctx = FPPipeContext(pspec)
-
-        # this is complicated: it's a workaround, due to the
-        # array-indexing not working properly in nmigen.
-        # self.ports() is used to access the ArrayProxy objects by name,
-        # however it doesn't work recursively.  the workaround:
-        # drop the sub-objects into *this* scope and they can be
-        # accessed / set.  it's horrible.
-        self.muxid = self.ctx.muxid
-        self.op = self.ctx.op
-
-    def eq(self, i):
-        return [self.z.eq(i.z), self.ctx.eq(i.ctx)]
-
-    def __iter__(self):
-        yield self.z
-        yield from self.ctx
-
-    def ports(self):
-        return list(self)
+from ieee754.fpcommon.packdata import FPPackData
 
 
 class FPPackMod(PipeModBase):
diff --git a/src/ieee754/fpcommon/packdata.py b/src/ieee754/fpcommon/packdata.py
new file mode 100644 (file)
index 0000000..40cd7e1
--- /dev/null
@@ -0,0 +1,33 @@
+# IEEE Floating Point Adder (Single Precision)
+# Copyright (C) Jonathan P Dawson 2013
+# 2013-12-12
+
+from nmigen import Signal
+from ieee754.fpcommon.getop import FPPipeContext
+
+
+class FPPackData:
+
+    def __init__(self, pspec):
+        width = pspec.width
+        self.z = Signal(width, reset_less=True)    # result
+        self.ctx = FPPipeContext(pspec)
+
+        # this is complicated: it's a workaround, due to the
+        # array-indexing not working properly in nmigen.
+        # self.ports() is used to access the ArrayProxy objects by name,
+        # however it doesn't work recursively.  the workaround:
+        # drop the sub-objects into *this* scope and they can be
+        # accessed / set.  it's horrible.
+        self.muxid = self.ctx.muxid
+        self.op = self.ctx.op
+
+    def eq(self, i):
+        return [self.z.eq(i.z), self.ctx.eq(i.ctx)]
+
+    def __iter__(self):
+        yield self.z
+        yield from self.ctx
+
+    def ports(self):
+        return list(self)