workaround bug in use of ArrayProxy iteration / assignment
[ieee754fpu.git] / src / ieee754 / fpcommon / pack.py
index 7fe1a7c7490ad196418ee294a791e5020d636d11..eae7c6b7da36a6f0c79597ec4035d3aec5de6edc 100644 (file)
@@ -12,13 +12,31 @@ from nmutil.singlepipe import Object
 from ieee754.fpcommon.getop import FPPipeContext
 
 
-class FPPackData(Object):
+class FPPackData:
 
     def __init__(self, width, pspec):
-        Object.__init__(self)
         self.z = Signal(width, reset_less=True)    # result
         self.ctx = FPPipeContext(width, 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)
+
 
 class FPPackMod(Elaboratable):