""" Pipeline builder stage with auto generation of pipeline registers.
"""
- def __init__(self, pipe, prev=None):
- self._pipe = pipe
+ def __init__(self, m, prev=None):
+ self._m = m
self._preg_map = {}
self._prev_stage = prev
if prev:
if next_stage not in self._preg_map:
self._preg_map[next_stage] = {}
self._preg_map[next_stage][name] = new_pipereg
- self._pipe.sync += eq(new_pipereg, value)
+ self._m.d.sync += eq(new_pipereg, value)
class PipeManager:
- def __init__(self, pipe):
- self._pipe = pipe
+ def __init__(self, m):
+ self.m = m
@contextmanager
def Stage(self, prev=None):
- stage = PipelineStage(self._pipe, prev)
+ stage = PipelineStage(self.m, prev)
try:
- yield stage
+ yield stage, stage._m
finally:
pass
def __init__(self):
self.m = Module()
self._loopback = Signal(4)
- PipeManager.__init__(self, self.m.d)
+ PipeManager.__init__(self, self.m)
def stage0(self):
self.n = ~self._loopback
def get_fragment(self, platform=None):
- with self.Stage() as p:
+ with self.Stage() as (p, m):
p.n = ~self._loopback
- with self.Stage(p) as p:
+ with self.Stage(p) as (p, m):
p.n = p.n + 2
+ with self.Stage(p) as (p, m):
+ localv = Signal(4)
+ m.d.comb += localv.eq(2)
+ p.n = p.n << localv
return self.m