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

r_data is undefined after a simultaneous write to an empty AsyncFIFO #217

Open
nmigen-issue-migration opened this issue Sep 20, 2019 · 2 comments

Comments

@nmigen-issue-migration
Copy link

Issue by whitequark
Friday Sep 20, 2019 at 20:02 GMT
Originally opened as m-labs/nmigen#217


The behavior of a dual port block RAM with read and write ports in different clock domains is not defined during a simultaneous read and write to the same address. (In fact it is not possible to make it defined.) However, this is exactly what is happening when an element is written into an empty AsyncFIFO[Buffered], since the produce and consume pointers are equal. If the phase of read and write clocks is just wrong, the output register of the BRAM could end in a metastable state.

It is not clear how this can be fixed. A workaround is to use AsyncFIFOBuffered instead, which resynchronizes the BRAM output.

@nmigen-issue-migration
Copy link
Author

Comment by whitequark
Friday Sep 20, 2019 at 20:57 GMT


I think what Xilinx does here is they require you to add a pipeline register in the dual-clock FIFO, effectively constructing a 2FF synchronizer out of the BRAM output register and the pipeline register.
Screenshot_20190920_205656

Which seems fine semantically, but... does this mean that bare AsyncFIFO should never be used?

@whitequark
Copy link
Member

To fix this problem, we can add a small amount of logic that prevents this kind of condition from arising. We can convince ourselves that it's sound using formal verification.

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

No branches or pull requests

2 participants