# connect front and back of chain to ourselves
front = pipechain[0] # first in chain
end = pipechain[-1] # last in chain
- self.set_specs(front, end) # NOTE: REPLACES existing data
+ self.set_specs(front, end) # sets up ispec/ospec functions
self._new_data("chain") # NOTE: REPLACES existing data
eqs += front._connect_in(self) # front p to our p
eqs += end._connect_out(self) # end n to out n
return _spec(self._ispecfn, name)
def set_specs(self, p, n):
- self._ispecfn = p.stage.ispec
- self._ospecfn = n.stage.ospec
+ """ sets up the ispecfn and ospecfn for getting input and output data
+ """
+ if hasattr(p, "stage"):
+ p = p.stage
+ if hasattr(n, "stage"):
+ n = n.stage
+ self._ispecfn = p.ispec
+ self._ospecfn = n.ospec
def new_specs(self, name):
""" allocates new ispec and ospec pair
return i
-class StageChain(StageCls):
+class StageChain(StageHelper):
""" pass in a list of stages, and they will automatically be
chained together via their input and output specs into a
combinatorial chain, to create one giant combinatorial block.
def __init__(self, chain, specallocate=False):
assert len(chain) > 0, "stage chain must be non-zero length"
self.chain = chain
+ StageHelper.__init__(self, None)
self.setup = self._sa_setup if specallocate else self._na_setup
-
- def ispec(self):
- """ returns the ispec of the first of the chain
- """
- return _spec(self.chain[0].ispec, "chainin")
-
- def ospec(self):
- """ returns the ospec of the last of the chain
- """
- return _spec(self.chain[-1].ospec, "chainout")
+ self.set_specs(self.chain[0], self.chain[-1])
def _sa_setup(self, m, i):
for (idx, c) in enumerate(self.chain):