mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
migen/actorlib/fifo: add FIFO wrapper function
Allow automatic instantiation of the correct fifo (SyncFIFO or AsyncFIFO) according to the clock domains passed in argument.
This commit is contained in:
parent
1f1ff5a5e9
commit
d0a19c4be8
1 changed files with 12 additions and 0 deletions
|
@ -55,3 +55,15 @@ class SyncFIFO(_FIFOActor):
|
|||
class AsyncFIFO(_FIFOActor):
|
||||
def __init__(self, layout, depth):
|
||||
_FIFOActor.__init__(self, fifo.AsyncFIFO, layout, depth)
|
||||
|
||||
|
||||
def FIFO(layout, depth, buffered=False,
|
||||
sink_cd="sys", source_cd="sys"):
|
||||
if sink_cd != source_cd:
|
||||
if buffered:
|
||||
ValueError("AsyncFIFO does not support buffered mode")
|
||||
fifo = AsyncFIFO(layout, depth)
|
||||
return ClockDomainsRenamer({"write": sink_cd, "read": source_cd})(fifo)
|
||||
else:
|
||||
fifo = SyncFIFO(layout, depth, buffered)
|
||||
return ClockDomainsRenamer(sink_cd)(fifo)
|
||||
|
|
Loading…
Reference in a new issue