From f098eca99df0d0a4bb61066a149e3849057759a6 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 28 Mar 2019 16:31:05 +0000 Subject: [PATCH] add new mode to StageChain which uses python output variables instead of allocating ispec/ospec --- src/add/singlepipe.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/add/singlepipe.py b/src/add/singlepipe.py index ffd515f6..a5e00750 100644 --- a/src/add/singlepipe.py +++ b/src/add/singlepipe.py @@ -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): -- 2.30.2