add new mode to StageChain which uses python output variables
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 28 Mar 2019 16:31:05 +0000 (16:31 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 28 Mar 2019 16:31:05 +0000 (16:31 +0000)
instead of allocating ispec/ospec

src/add/singlepipe.py

index ffd515f6f5920012380d819e12a502eb1f994b2c..a5e00750405e16260bd9d06d8454ae04feeade05 100644 (file)
@@ -351,8 +351,9 @@ class StageChain(StageCls):
         * output of second goes into input into third (etc. etc.)
         * the output of this class will be the output of the last stage
     """
-    def __init__(self, chain):
+    def __init__(self, chain, specallocate=False):
         self.chain = chain
+        self.specallocate = specallocate
 
     def ispec(self):
         return self.chain[0].ispec()
@@ -364,12 +365,17 @@ class StageChain(StageCls):
         for (idx, c) in enumerate(self.chain):
             if hasattr(c, "setup"):
                 c.setup(m, i)               # stage may have some module stuff
-            o = self.chain[idx].ospec()     # only the last assignment survives
-            m.d.comb += eq(o, c.process(i)) # process input into "o"
+            if self.specallocate:
+                o = self.chain[idx].ospec()     # last assignment survives
+                m.d.comb += eq(o, c.process(i)) # process input into "o"
+            else:
+                o = c.process(i) # store input into "o"
             if idx != len(self.chain)-1:
-                ni = self.chain[idx+1].ispec() # becomes new input on next loop
-                m.d.comb += eq(ni, o)          # assign output to next input
-                i = ni
+                if self.specallocate:
+                    ni = self.chain[idx+1].ispec() # new input on next loop
+                    m.d.comb += eq(ni, o)          # assign to next input
+                else:
+                    i = o
         self.o = o                             # last loop is the output
 
     def process(self, i):