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

AsyncFIFOBuffered {r,w}_level fixes #571

Merged

Conversation

rroohhh
Copy link
Contributor

@rroohhh rroohhh commented Jan 2, 2021

This includes a number of fixes for {r,w}_level in AsyncFIFOBuffered.

  1. The accounting for the output register used AsyncFFSynchronizer instead of FFSynchronizer. This is wrong as we want to synchronize both edges
  2. Use the proper clock domains in the tests (not really a bug in the fifo logic obviously)
  3. The FFSynchronizer should have a latency of 4 to match the latency of consume_w_bin / w_level. Two cycles for the FFSynchronizer from the read to the write domain of consume_w_gry, one for the GrayDecoder and one for the w_level calculation.
  4. Fix the output register accounting. If the user asserts r_en even if r_rdy is low, we get -1 in the intermediate calculation which overflows to 1 as we have a unsigned Signal

Let me know if I should split this into multiple PRs or elaborate more on the fixes. The last two include additional testcases that fail without the fix. I did not include a testcase for the AsyncFFSynchronizer to FFSynchronizer change, as this is obviously wrong and would be hard to properly test without proper multi clock support in formal.

@codecov
Copy link

codecov bot commented Jan 2, 2021

Codecov Report

Merging #571 (301a875) into master (b466b72) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #571   +/-   ##
=======================================
  Coverage   81.50%   81.50%           
=======================================
  Files          49       49           
  Lines        6461     6461           
  Branches     1287     1287           
=======================================
  Hits         5266     5266           
  Misses       1008     1008           
  Partials      187      187           
Impacted Files Coverage Δ
nmigen/lib/fifo.py 94.08% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b466b72...301a875. Read the comment docs.

@whitequark
Copy link
Member

Let me know if I should split this into multiple PRs or elaborate more on the fixes.

Everything looks good. However, does anyone remember how we ended using AsyncFFSynchronizer there in the first place? I vaguely remember that the ability to use it there motivated a refactoring elsewhere, so it was probably not a simple typo, and I'd like to understand why it's there before we change it. It is also possible that I misremember.

@anuejn
Copy link
Contributor

anuejn commented Jan 3, 2021

To me it happens quite often that I end up using AsyncFFSyncronizer by accident because of the naming. My thought process is something like "I need to synchronize a signal that is async to $domain into $domain. Must be AsyncFFSyncronizer". I think it is very likely that it slipped in there similarly?

@whitequark
Copy link
Member

@awygle mentioned on IRC that he thinks it's deliberate; let's wait for him to investigate.

@awygle
Copy link
Contributor

awygle commented Jan 5, 2021

I misread this because of what @whitequark said about it motivating a refactoring. This is a different case than what I was thinking of (the reset AsyncFFSynchronizer, which is what that module was invented for). This seems correct to me, I am OK with merging it.

@whitequark whitequark merged commit 9af8201 into amaranth-lang:master Jan 6, 2021
@whitequark
Copy link
Member

Thanks everyone!

@rroohhh rroohhh deleted the fix_async_fifo_buffered_level branch January 6, 2021 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants