lib.fifo: make simulation read() and write() functions compat-only.

These functions were originally changed in 3ed51938, in an attempt
to make them take one cycle instead of two. However, this does not
actually work because of drawbacks of the simulator interface.

Avoid committing to any specific implementation for now, and instead
make them compat-only extensions.
This commit is contained in:
whitequark 2019-09-23 08:45:58 +00:00
parent 1976310bf0
commit a57b76fb5d
3 changed files with 23 additions and 54 deletions

View file

@ -5,42 +5,6 @@ from ..back.pysim import *
from ..lib.fifo import *
class FIFOSmokeTestCase(FHDLTestCase):
def assertSyncFIFOWorks(self, fifo, xfrm=lambda x: x):
with Simulator(xfrm(Fragment.get(fifo, None)), vcd_file=open("test.vcd", "w")) as sim:
sim.add_clock(1e-6)
def process():
yield from fifo.write(1)
yield from fifo.write(2)
while not (yield fifo.r_rdy):
yield
if not fifo.fwft:
yield fifo.r_en.eq(1)
yield
self.assertEqual((yield from fifo.read()), 1)
self.assertEqual((yield from fifo.read()), 2)
sim.add_sync_process(process)
sim.run()
def assertAsyncFIFOWorks(self, fifo):
self.assertSyncFIFOWorks(fifo, xfrm=DomainRenamer({"read": "sync", "write": "sync"}))
def test_sync_fwft(self):
self.assertSyncFIFOWorks(SyncFIFO(width=8, depth=4, fwft=True))
def test_sync_not_fwft(self):
self.assertSyncFIFOWorks(SyncFIFO(width=8, depth=4, fwft=False))
def test_sync_buffered(self):
self.assertSyncFIFOWorks(SyncFIFOBuffered(width=8, depth=4))
def test_async(self):
self.assertAsyncFIFOWorks(AsyncFIFO(width=8, depth=4))
def test_async_buffered(self):
self.assertAsyncFIFOWorks(AsyncFIFOBuffered(width=8, depth=3))
class FIFOModel(Elaboratable, FIFOInterface):
"""
Non-synthesizable first-in first-out queue, implemented naively as a chain of registers.