new non-buffer sync pipe class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 7 Apr 2019 10:26:18 +0000 (11:26 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 7 Apr 2019 10:26:18 +0000 (11:26 +0100)
src/add/singlepipe.py
src/add/test_buf_pipe.py

index b27e90ef75e9690b20061590f1ba5538d0bbee21..62a5e641f8ae6f408a4f380f482033471877ccc6 100644 (file)
@@ -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
 
 
index d9cee5616ce9c3fc98c0dcda30daba64a6f79ffd..ce54eb4d5f4e6d505fe23c136887e60996bf9b84 100644 (file)
@@ -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