From 04dd459f2aeab2fb2e53280ca517b7d3ef4da92c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 2 Apr 2019 18:52:01 +0100 Subject: [PATCH] continuing to experiment with pipeline, outputs still not connected --- src/add/pipeline.py | 26 ++++++++++++++++++-------- src/add/pipeline_example.py | 3 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/add/pipeline.py b/src/add/pipeline.py index 45070322..e3983e3a 100644 --- a/src/add/pipeline.py +++ b/src/add/pipeline.py @@ -96,7 +96,7 @@ class ObjectProxy: if isinstance(a, Signal) or isinstance(a, ObjectProxy) or \ isinstance(a, Record): res.append(a) - print ("ObjectPorts", res) + #print ("ObjectPorts", res) return res def __getattr__(self, name): @@ -188,6 +188,7 @@ class PipelineStage: if isinstance(value, ObjectProxy): print ("OP, assigns:", value._assigns) self._assigns += value._assigns + #self._eqs += value._eqs #self._m.d.comb += assign self._assigns += assign elif self._m: @@ -198,27 +199,33 @@ class PipelineStage: print ("!pipemode !m: defer assign", new_pipereg, value) assign = eq(new_pipereg, value) self._assigns += assign + if isinstance(value, ObjectProxy): + print ("OP, defer assigns:", value._assigns) + self._assigns += value._assigns +def likelist(specs): + res = [] + for v in specs: + res.append(like(v, v.name, None, pipemode=True)) + return res class AutoStage(StageCls): def __init__(self, inspecs, outspecs, eqs, assigns): self.inspecs, self.outspecs = inspecs, outspecs self.eqs, self.assigns = eqs, assigns #self.o = self.ospec() - def ispec(self): return self.like(self.inspecs) - def ospec(self): return self.like(self.outspecs) - def like(self, specs): - res = [] - for v in specs: - res.append(like(v, v.name, None, pipemode=True)) - return res + def ispec(self): return likelist(self.inspecs) + def ospec(self): return likelist(self.outspecs) def process(self, i): print ("stage process", i) return self.eqs def setup(self, m, i): + #self.o = self.ospec() + m.d.comb += eq(self.inspecs, i) print ("stage setup", i) + print ("stage setup inspecs", self.inspecs) #m.d.comb += eq(self.o, i) @@ -243,6 +250,8 @@ class PipeManager: @contextmanager def Stage(self, name, prev=None, ispec=None): print ("start stage", name) + if ispec: + ispec = likelist(ispec) stage = PipelineStage(name, None, prev, self.pipemode, ispec=ispec) try: yield stage, self.m #stage._m @@ -254,6 +263,7 @@ class PipeManager: inspecs = stage._ispec else: inspecs = self.get_specs(stage, name) + inspecs = likelist(inspecs) outspecs = self.get_specs(stage, '__nextstage__', liked=True) eqs = get_eqs(stage._eqs) assigns = get_assigns(stage._assigns) diff --git a/src/add/pipeline_example.py b/src/add/pipeline_example.py index b84496e7..74c1c5fd 100644 --- a/src/add/pipeline_example.py +++ b/src/add/pipeline_example.py @@ -130,10 +130,11 @@ class PipelineStageObjectExample: #m.d.comb += self.obj.a.eq(localv2 + 1) #m.d.sync += self._loopback.eq(localv2) + ispec= [self._loopback, self._obj] with PipeManager(m, pipemode=True) as pipe: with pipe.Stage("first", - ispec=[self._loopback, self._obj]) as (p, m): + ispec=ispec) as (p, m): p.n = ~self._loopback p.o = self._obj with pipe.Stage("second", p) as (p, m): -- 2.30.2