Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement almost_full and almost_empty for Synchronous FIFOs #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

occheung
Copy link
Contributor

Description

This PR introduces FIFO watermark configuration.

  • When the FIFO level reaches the high watermark (inclusive), almost_full is asserted.
  • When the FIFO level does not exceed the low watermark (inclusive), almost_empty is asserted.

Comment on lines 85 to 100
def add_almost_full(self, hi_wm):
self.almost_full = Signal()
if hi_wm.bit_count() == 1:
self.comb += self.almost_full.eq(
reduce(or_, [level_i for level_i in self.level[log2_int(hi_wm):]]))
else:
self.comb += self.almost_full.eq(self.level >= hi_wm)

def add_almost_empty(self, lo_wm):
self.almost_empty = Signal()
if lo_wm.bit_count() == 1:
self.comb += self.almost_empty.eq(
reduce(and_, [~level_i for level_i in self.level[log2_int(lo_wm):]]) | (self.level == lo_wm))
else:
self.comb += self.almost_empty.eq(self.level <= lo_wm)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what those functions are supposed to do, in any case FIFOInterface isn't a Module and self.comb cannot be used there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are also definitely incorrect in the case of an asynchronous FIFO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants