# set up the input and output data
if stage is not None:
- self._new_data(self, self, "data")
+ self._new_data("data")
- def _new_data(self, p, n, name):
+ def _new_data(self, name):
""" allocates new data_i and data_o
"""
- self.p.data_i = _spec(p.stage.ispec, "%s_i" % name)
- self.n.data_o = _spec(n.stage.ospec, "%s_o" % name)
+ self.p.data_i, self.n.data_o = self.new_specs(name)
@property
def data_r(self):
# connect front and back of chain to ourselves
front = pipechain[0] # first in chain
end = pipechain[-1] # last in chain
- self._new_data(front, end, "chain") # NOTE: REPLACES existing data
+ self.set_specs(front, end) # NOTE: REPLACES existing data
+ 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
"""
def __init__(self, stage):
self.stage = stage
+ self._ispecfn = None
+ self._ospecfn = None
+ if stage is not None:
+ self.set_specs(self, self)
def ospec(self, name):
- assert self.stage is not None
- return _spec(self.stage.ospec, name)
+ assert self._ospecfn is not None
+ return _spec(self._ospecfn, name)
def ispec(self, name):
- assert self.stage is not None
- return _spec(self.stage.ispec, name)
+ assert self._ispecfn is not None
+ return _spec(self._ispecfn, name)
+
+ def set_specs(self, p, n):
+ self._ispecfn = p.stage.ispec
+ self._ospecfn = n.stage.ospec
+
+ def new_specs(self, name):
+ """ allocates new ispec and ospec pair
+ """
+ return self.ispec("%s_i" % name), self.ospec("%s_o" % name)
def process(self, i):
if self.stage and hasattr(self.stage, "process"):