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
from random import randint, seed
-seed(4)
+#seed(4)
def check_o_n_valid(dut, val):
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
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