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

@ -1,4 +1,4 @@
from ...tools import deprecated
from ...tools import deprecated, extend
from ...lib.fifo import FIFOInterface as NativeFIFOInterface, \
SyncFIFO, SyncFIFOBuffered, AsyncFIFO, AsyncFIFOBuffered
@ -14,3 +14,25 @@ class CompatFIFOInterface(NativeFIFOInterface):
_FIFOInterface = CompatFIFOInterface
@extend(NativeFIFOInterface)
def read(self):
"""Read method for simulation."""
assert (yield self.r_rdy)
value = (yield self.r_data)
yield self.r_en.eq(1)
yield
yield self.r_en.eq(0)
yield
return value
@extend(NativeFIFOInterface)
def write(self, data):
"""Write method for simulation."""
assert (yield self.w_rdy)
yield self.w_data.eq(data)
yield self.w_en.eq(1)
yield
yield self.w_en.eq(0)
yield