- o_p_busyn = Signal(reset_less=True)
- o_n_stbn = Signal(reset_less=True)
- i_n_busyn = Signal(reset_less=True)
- i_p_stb_o_p_busyn = Signal(reset_less=True)
- m.d.comb += i_n_busyn.eq(~self.i_n_busy)
- m.d.comb += o_n_stbn.eq(~self.o_n_stb)
- m.d.comb += o_p_busyn.eq(~self.o_p_busy)
- m.d.comb += i_p_stb_o_p_busyn.eq(self.i_p_stb & o_p_busyn)
-
- result = Signal(32)
- m.d.comb += result.eq(self.process(self.i_data))
- with m.If(o_p_busyn): # not stalled
- m.d.sync += self.r_data.eq(result)
-
- #with m.If(self.i_p_rst): # reset
- # m.d.sync += self.o_n_stb.eq(0)
- # m.d.sync += self.o_p_busy.eq(0)
- with m.If(i_n_busyn): # next stage is not busy
- with m.If(o_p_busyn): # not stalled
- # nothing in buffer: send input direct to output
- m.d.sync += self.o_n_stb.eq(self.i_p_stb)
- m.d.sync += self.o_data.eq(result)
- with m.Else(): # o_p_busy is true, and something is in our buffer.
+ # establish some combinatorial temporaries
+ o_n_validn = Signal(reset_less=True)
+ i_p_valid_o_p_ready = Signal(reset_less=True)
+ m.d.comb += [o_n_validn.eq(~self.o.n_valid),
+ i_p_valid_o_p_ready.eq(self.i.p_valid & self.o.p_ready),
+ ]
+
+ # store result of processing in combinatorial temporary
+ with m.If(self.i.p_valid): # input is valid: process it
+ m.d.comb += eq(self.result, self.stage.process(self.i.data))
+ # if not in stall condition, update the temporary register
+ with m.If(self.o.p_ready): # not stalled
+ m.d.sync += self.update_buffer()
+
+ #with m.If(self.i.p_rst): # reset
+ # m.d.sync += self.o.n_valid.eq(0)
+ # m.d.sync += self.o.p_ready.eq(0)
+ with m.If(self.i.n_ready): # next stage is ready
+ with m.If(self.o.p_ready): # not stalled
+ # nothing in buffer: send (processed) input direct to output
+ m.d.sync += [self.o.n_valid.eq(self.i.p_valid),
+ self.update_output(),
+ ]
+ with m.Else(): # o.p_ready is false, and something is in buffer.