enjoy-digital / litedram

Small footprint and configurable DRAM core
Other
365 stars 115 forks source link

CDC synchronization of CSRs in LiteDRAMBISTGenerator/LiteDRAMBISTChecker #167

Closed jedrzejboczar closed 4 years ago

jedrzejboczar commented 4 years ago

This issue describes problem from https://github.com/enjoy-digital/litedram/pull/165#issuecomment-599629743.

When the memory port passed to LiteDRAMBISTGenerator/LiteDRAMBISTChecker is not in sys clock domain, then synchronization is added for CSRs. The problem is that synchronization of multi-bit CSRs like base takes longer than synchronization of single-bit ones, like start. This results in a situation where, even though we write to base first and then to start, it may happend that start propagates fast enough that the LiteDRAMBISTGenerator module will use old value of base when writing first word. This is similar for LiteDRAMBISTChecker, where errors do not have final value at the moment when done is already 1.

Should we add additional synchronization of start/done to account for that?

A test for this situation has been added in https://github.com/enjoy-digital/litedram/pull/165: test_bist_csr_cdc. Simulation data from the test can be found in sim-gtkwave.zip (includes all stages of bist_test, with errors == 4 asserion commented out).

test_bist_csr_cdc fails due to (referring to the stages from bist_test method):

enjoy-digital commented 4 years ago

Thanks for the detailed report. The CDC has been refactored with https://github.com/enjoy-digital/litedram/commit/92e34d4d376b1f62de1d85a58a396c3fa224b67b and the test has been enabled with https://github.com/enjoy-digital/litedram/commit/c55136c17ae13a026097c9da2b88143fd1276eab and is now passing.