This repository was archived by the owner on Jan 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
migen.genlib: Improve "first word fall through" docs. #152
Open
mithro
wants to merge
1
commit into
m-labs:master
Choose a base branch
from
mithro:fwft-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−11
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,10 @@ class _FIFOInterface: | |
| Bit width for the data. | ||
| depth : int | ||
| Depth of the FIFO. | ||
| fwft : bool (optional) | ||
| Enable the FIFO to have "first word fall through". The first | ||
| word written to an otherwise empty FIFO will be put on the | ||
| output without doing a read first. | ||
|
|
||
| Attributes | ||
| ---------- | ||
|
|
@@ -48,7 +52,8 @@ class _FIFOInterface: | |
| Acknowledge `dout`. If asserted, the next entry will be | ||
| available on the next cycle (if `readable` is high then). | ||
| """ | ||
| def __init__(self, width, depth): | ||
|
|
||
| def __init__(self, width, depth, fwft=False): | ||
| self.we = Signal() | ||
| self.writable = Signal() # not full | ||
| self.re = Signal() | ||
|
|
@@ -94,7 +99,7 @@ class SyncFIFO(Module, _FIFOInterface): | |
| __doc__ = __doc__.format(interface=_FIFOInterface.__doc__) | ||
|
|
||
| def __init__(self, width, depth, fwft=True): | ||
| _FIFOInterface.__init__(self, width, depth) | ||
| _FIFOInterface.__init__(self, width, depth, fwft) | ||
|
|
||
| self.level = Signal(max=depth+1) | ||
| self.replace = Signal() | ||
|
|
@@ -146,11 +151,18 @@ def __init__(self, width, depth, fwft=True): | |
|
|
||
|
|
||
| class SyncFIFOBuffered(Module, _FIFOInterface): | ||
| """Has an interface compatible with SyncFIFO with fwft=True, | ||
| but does not use asynchronous RAM reads that are not compatible | ||
| with block RAMs. Increases latency by one cycle.""" | ||
| def __init__(self, width, depth): | ||
| _FIFOInterface.__init__(self, width, depth) | ||
| """SyncFIFO compatible with "first word fall through" without using async memory. | ||
|
|
||
| The SyncFIFOBuffered has an interface compatible with SyncFIFO with | ||
| `fwft=True` but does not use asynchronous RAM reads that are not compatible | ||
| with block RAMs. Increases latency by one cycle. | ||
|
|
||
| This is useful for providing a SyncFIFO when the FPGA part doesn't provide | ||
| block ram with an asynchronous read port, like the Lattice iCE40 parts. | ||
| """ | ||
| def __init__(self, width, depth, fwft=True): | ||
| assert fwft, "fwft should be set, otherwise just use a SyncFIFO." | ||
| _FIFOInterface.__init__(self, width, depth, False) | ||
| self.submodules.fifo = fifo = SyncFIFO(width, depth, False) | ||
|
|
||
| self.writable = fifo.writable | ||
|
|
@@ -182,8 +194,9 @@ class AsyncFIFO(Module, _FIFOInterface): | |
| """ | ||
| __doc__ = __doc__.format(interface=_FIFOInterface.__doc__) | ||
|
|
||
| def __init__(self, width, depth): | ||
| _FIFOInterface.__init__(self, width, depth) | ||
| def __init__(self, width, depth, fwft=False): | ||
| assert not fwft, "fwft is not supported on the AsyncFIFO." | ||
| _FIFOInterface.__init__(self, width, depth, fwft=False) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a sync FIFO it's either:
The async FIFO does not have to make this compromise (the latency is already high enough from the CDC and hides the memory latency). |
||
|
|
||
| ### | ||
|
|
||
|
|
@@ -235,8 +248,8 @@ class AsyncFIFOBuffered(Module, _FIFOInterface): | |
| """Improves timing when it breaks due to sluggish clock-to-output | ||
| delay in e.g. Xilinx block RAMs. Increases latency by one cycle.""" | ||
| def __init__(self, width, depth): | ||
| _FIFOInterface.__init__(self, width, depth) | ||
| self.submodules.fifo = fifo = AsyncFIFO(width, depth) | ||
| _FIFOInterface.__init__(self, width, depth, fwft=False) | ||
| self.submodules.fifo = fifo = AsyncFIFO(width, depth, fwft) | ||
|
|
||
| self.writable = fifo.writable | ||
| self.din = fifo.din | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIFOInterfacedoes not usefwftand therefore should not have this parameter.