workaround bug in use of ArrayProxy iteration / assignment
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 2 Jul 2019 12:47:50 +0000 (13:47 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 2 Jul 2019 12:47:50 +0000 (13:47 +0100)
src/ieee754/fpcommon/getop.py
src/ieee754/fpcommon/normtopack.py
src/ieee754/fpcommon/pack.py
src/nmutil/nmoperator.py

index 0100880cd7967297974f589495256d09ca9dbb4d..abe7dc94abcf69dcd53f82c6a77e312dfc92746f 100644 (file)
@@ -94,14 +94,12 @@ class FPPipeContext:
 
     def eq(self, i):
         ret = [self.muxid.eq(i.muxid)]
-        if self.op_wid:
-            ret.append(self.op.eq(i.op))
+        ret.append(self.op.eq(i.op))
         return ret
 
     def __iter__(self):
         yield self.muxid
-        if self.op_wid:
-            yield self.op
+        yield self.op
 
     def ports(self):
         return list(self)
index 0f05795a9a75b0ee7a04c3cc750034d41a3a3781..1cda87659aab349853de9ce13d5e6806fabc852a 100644 (file)
@@ -18,6 +18,7 @@ class FPNormToPack(FPState, SimpleHandshake):
 
     def __init__(self, width, pspec):
         FPState.__init__(self, "normalise_1")
+        print ("normtopack", pspec)
         self.pspec = pspec
         self.width = width
         SimpleHandshake.__init__(self, self) # pipeline is its own stage
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):
 
index 9a50f65032b885614d9fbb390d5f1af4feb60960..c035c37ca2372b6e95e3d51c73ac5c213a5dcead 100644 (file)
@@ -93,6 +93,7 @@ class Visitor2:
             yield from self.iterator2(ao.fields[field_name], val)
 
     def arrayproxy_iter2(self, ao, ai):
+        print ("arrayproxy_iter2", ai.ports(), ai, ao)
         for p in ai.ports():
             print ("arrayproxy - p", p, p.name, ao)
             op = getattr(ao, p.name)