From 8c9eab17c183606e9ac89be22b58ed33d8f4cac8 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 28 Mar 2019 03:45:36 +0000 Subject: [PATCH] complicated. change ControlBase.connect API to return list of eq statements nmigen module elaborate is not done recursively on submodules in depth-first order. connect fn was having a side-effect of establishing the p.i_data and n.o_data... which were not set up from a submodule yet. --- src/add/nmigen_add_experiment.py | 5 ++--- src/add/singlepipe.py | 9 ++++----- src/add/test_buf_pipe.py | 5 +---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 92588762..4b4d9116 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -1894,13 +1894,12 @@ class FPADDBasePipe(ControlBase): def __init__(self, width, id_wid): ControlBase.__init__(self) self.pipe1 = FPADDBasePipe1(width, id_wid) - self.p.i_data = self.pipe1.stage.ispec() - self.n.o_data = self.pipe1.stage.ospec() + self._eqs = self.connect([self.pipe1]) def elaborate(self, platform): m = Module() m.submodules.pipe1 = self.pipe1 - self.connect(m, [self.pipe1]) + m.d.comb += self._eqs return m diff --git a/src/add/singlepipe.py b/src/add/singlepipe.py index 3150d389..775081f3 100644 --- a/src/add/singlepipe.py +++ b/src/add/singlepipe.py @@ -411,7 +411,7 @@ class ControlBase: """ return self.n._connect_out(nxt.n) - def connect(self, m, pipechain): + def connect(self, pipechain): """ connects a chain (list) of Pipeline instances together and links them to this ControlBase instance: @@ -451,16 +451,15 @@ class ControlBase: # connect front of chain to ourselves front = pipechain[0] - #self.p.i_data = front.stage.ispec() + self.p.i_data = front.stage.ispec() eqs += front._connect_in(self) # connect end of chain to ourselves end = pipechain[-1] - #self.n.o_data = end.stage.ospec() + self.n.o_data = end.stage.ospec() eqs += end._connect_out(self) - # activate the assignments - m.d.comb += eqs + return eqs def set_input(self, i): """ helper function to set the input data diff --git a/src/add/test_buf_pipe.py b/src/add/test_buf_pipe.py index f4764974..af725d23 100644 --- a/src/add/test_buf_pipe.py +++ b/src/add/test_buf_pipe.py @@ -291,13 +291,10 @@ class ExampleBufPipe2(ControlBase): pipe1 = ExampleBufPipe() pipe2 = ExampleBufPipe() - self.p.i_data = pipe1.stage.ispec() - self.n.o_data = pipe2.stage.ospec() - m.submodules.pipe1 = pipe1 m.submodules.pipe2 = pipe2 - self.connect(m, [pipe1, pipe2]) + m.d.comb += self.connect([pipe1, pipe2]) return m -- 2.30.2