From e3639a2c155b7c12fbd0927dd2d1f73ce7eb1683 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 7 Apr 2019 11:26:18 +0100 Subject: [PATCH] new non-buffer sync pipe class --- src/add/singlepipe.py | 39 +++++++++++++-------------------------- src/add/test_buf_pipe.py | 6 +++--- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/add/singlepipe.py b/src/add/singlepipe.py index b27e90ef..62a5e641 100644 --- a/src/add/singlepipe.py +++ b/src/add/singlepipe.py @@ -679,47 +679,34 @@ class BufferedPipeline2(ControlBase): self.m = ControlBase._elaborate(self, platform) result = self.stage.ospec() - r_busy = Signal(reset=0) if hasattr(self.stage, "setup"): self.stage.setup(self.m, self.p.i_data) # establish some combinatorial temporaries - o_n_validn = Signal(reset_less=True) n_i_ready = Signal(reset_less=True, name="n_i_rdy_data") - o_n_valid_i_n_ready = Signal(reset_less=True) + p_i_valid_p_o_ready = Signal(reset_less=True) p_i_valid = Signal(reset_less=True) self.m.d.comb += [p_i_valid.eq(self.p.i_valid_test), - o_n_validn.eq(~self.n.o_valid), n_i_ready.eq(self.n.i_ready_test), - o_n_valid_i_n_ready.eq(self.n.o_valid & n_i_ready), + p_i_valid_p_o_ready.eq(p_i_valid & self.p.o_ready), ] # store result of processing in combinatorial temporary self.m.d.comb += eq(result, self.stage.process(self.p.i_data)) - with self.m.If(self.p.o_ready): # output is ready - with self.m.If(p_i_valid): # and input is valid - self.m.d.sync += [r_busy.eq(1), + # previous valid and ready + with self.m.If(p_i_valid_p_o_ready): + self.m.d.sync += [self.n.o_valid.eq(1), # output valid eq(self.n.o_data, result), # update output ] - # else stay in idle condition (output ready, but input wasn't valid) - - # output valid but not ready, and input is ready - with self.m.Elif(o_n_valid_i_n_ready): - # output transaction just took place - self.m.d.sync += [r_busy.eq(0), - self.n.o_valid.eq(0), # set output invalid - ] - # - with self.m.Elif(o_n_validn): - # can check here for data valid - self.m.d.sync += [self.n.o_valid.eq(1), - #eq(self.n.o_data, result), # update output - ] - - #self.m.d.comb += self.p._o_ready.eq(~r_busy) - self.m.d.comb += self.p._o_ready.eq(~(((~n_i_ready)&(self.n.o_valid))| \ - (r_busy))) + # previous invalid or not ready, however next is accepting + with self.m.Elif(n_i_ready): + # TODO: could still send data here (if there was any) + self.m.d.sync += self.n.o_valid.eq(0), # ...so set output invalid + + # if next is ready, so is previous + self.m.d.comb += self.p._o_ready.eq(n_i_ready) + return self.m diff --git a/src/add/test_buf_pipe.py b/src/add/test_buf_pipe.py index d9cee561..ce54eb4d 100644 --- a/src/add/test_buf_pipe.py +++ b/src/add/test_buf_pipe.py @@ -29,7 +29,7 @@ from singlepipe import BufferedPipeline2 from random import randint, seed -seed(4) +#seed(4) def check_o_n_valid(dut, val): @@ -210,7 +210,7 @@ class Test5: send = True else: send = randint(0, send_range) != 0 - send = True + #send = True o_p_ready = yield self.dut.p.o_ready if not o_p_ready: yield @@ -229,7 +229,7 @@ class Test5: stall_range = randint(0, 3) for j in range(randint(1,10)): ready = randint(0, stall_range) != 0 - ready = True + #ready = True yield self.dut.n.i_ready.eq(ready) yield o_n_valid = yield self.dut.n.o_valid -- 2.30.2