return self.s_o_ready # set dynamically by stage
return self._o_ready # return this when not under dynamic control
- def _connect_in(self, prev):
+ def _connect_in(self, prev, direct=False):
""" internal helper function to connect stage to an input source.
do not use to connect stage-to-stage!
"""
- return [self.i_valid.eq(prev.i_valid_test),
+ if direct:
+ i_valid = prev.i_valid
+ else:
+ i_valid = prev.i_valid_test
+ return [self.i_valid.eq(i_valid),
prev.o_ready.eq(self.o_ready),
eq(self.i_data, prev.i_data),
]
eq(nxt.i_data, self.o_data),
]
- def _connect_out(self, nxt):
+ def _connect_out(self, nxt, direct=False):
""" internal helper function to connect stage to an output source.
do not use to connect stage-to-stage!
"""
+ if direct:
+ i_ready = nxt.i_ready
+ else:
+ i_ready = nxt.i_ready_test
return [nxt.o_valid.eq(self.o_valid),
- self.i_ready.eq(nxt.i_ready_test),
+ self.i_ready.eq(i_ready),
eq(nxt.o_data, self.o_data),
]
self.m = m = ControlBase._elaborate(self, platform)
fifo = SyncFIFO(self.fwidth, self.fdepth)
+ m.submodules.fifo = fifo
# prev: make the FIFO "look" like a PrevControl...
fp = PrevControl()
- fp.i_valid = fifo.writable
- fp._o_ready = fifo.we
+ fp.i_valid = fifo.we
+ fp._o_ready = fifo.writable
fp.i_data = fifo.din
# ... so we can do this!
- m.d.comb += fp._connect_in(self)
+ m.d.comb += fp._connect_in(self.p, True)
# next: make the FIFO "look" like a NextControl...
fn = NextControl()
fn.i_ready = fifo.re
fn.o_data = fifo.dout
# ... so we can do this!
- m.d.comb += fn._connect_out(self)
+ m.d.comb += fn._connect_out(self.n)
# err... that should be all!
return m
from singlepipe import SimpleHandshake
from singlepipe import PassThroughHandshake
from singlepipe import PassThroughStage
+from singlepipe import FIFOtest
from random import randint, seed
return m
+######################################################################
+# Test 20
+######################################################################
+
+class FIFOTest16(FIFOtest):
+
+ def __init__(self):
+ FIFOtest.__init__(self, 16, 2)
+
+
######################################################################
# Test 997
######################################################################
with open("test_bufpass19.il", "w") as f:
f.write(vl)
+ print ("test 20")
+ dut = FIFOTest16()
+ data = data_chain1()
+ test = Test5(dut, test_identical_resultfn, data=data)
+ run_simulation(dut, [test.send, test.rcv], vcd_name="test_fifo20.vcd")
+ ports = [dut.p.i_valid, dut.n.i_ready,
+ dut.n.o_valid, dut.p.o_ready] + \
+ [dut.p.i_data] + [dut.n.o_data]
+ vl = rtlil.convert(dut, ports=ports)
+ with open("test_fifo20.il", "w") as f:
+ f.write(vl)
+
print ("test 997")
dut = ExampleBufPassThruPipe2()
data = data_chain1()