Configurable RWDS sampling and clock-start delay. #21
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.
A finalized version of #20
Current State: Tested in RTL simulation
During the Command-Address block of read and writes (except for zero-latency writes), the RWDS signal must be sampled to determine the additional latency required (1x the configured value if it is LOW, 2x if it is HIGH).
RWDS is driven from the device some times after CS is driven low by the controller and it is de-asserted by the device synchronous to the CK edge during the time the last CA data is stable.
For the worst case timing (t_DSV max, t_CSS min and t_CKDS min) the RWDS signal is only valid for about one clock period (two cycles to three cycles after CS going low).
It is important to mention that according to spec, the RWDS signal from the device and the clock start from the host are both referenced to the CS going low edge but not each other. Meaning in the case of a slower than spec'd clock, RWDS may arrive earlier than expected (even before the clock starts).
This presents us with two problems:
Fixing 1:
Solved by adding a separate module that counts clock edges after CS going low. This then enables a clock gate, propagating a single clock pulse to the sampling flip-flop. The exact edge where the sampling should occur is configurable.
A second flip-flop is added to cross the signal into the clk_phy domain the main FSM is in.
Fixing 2:
Two additions were made:
Together the clock-start and RWDS sampling time are a lot more configurable and should greatly increase the control, especially when operating with out-of-spec frequencies.
See Figure 9.4 and 9.5 in the spec (read timing diagrams) as well as table 9.4 (AC parameters). Consider that the diagrams are not to scale for a worst case transaction, t_DSV in particular is way too small.
The attached image show the relevant signal of the new RWDS sampler. The chip select to clock-start time

tcs->ck
can be increased from the minimum of one clock cycle.trwds
can be changed in 1/2 clock cycles steps with the minimum being 0.5 clock cycles (corresponding to the falling edge immediately after CS going low)