forked from M-Labs/artiq
sdram: simplify read level scan
This commit is contained in:
parent
845784c180
commit
4b3f408143
|
@ -316,11 +316,14 @@ mod ddr {
|
||||||
for n in 0..DQS_SIGNAL_COUNT {
|
for n in 0..DQS_SIGNAL_COUNT {
|
||||||
ddrphy::dly_sel_write(1 << (DQS_SIGNAL_COUNT - n - 1));
|
ddrphy::dly_sel_write(1 << (DQS_SIGNAL_COUNT - n - 1));
|
||||||
|
|
||||||
let find_edge = |which| {
|
|
||||||
// Find the first (which=true) or last (which=false) tap that leads to a
|
// Find the first (which=true) or last (which=false) tap that leads to a
|
||||||
// sufficiently high number of correct reads.
|
// sufficiently high number of correct reads.
|
||||||
let mut last_valid = 0;
|
let mut min_delay = 0;
|
||||||
|
let mut have_min_delay = false;
|
||||||
|
let mut max_delay = 0;
|
||||||
|
|
||||||
ddrphy::rdly_dq_rst_write(1);
|
ddrphy::rdly_dq_rst_write(1);
|
||||||
|
|
||||||
for delay in 0..DDRPHY_MAX_DELAY {
|
for delay in 0..DDRPHY_MAX_DELAY {
|
||||||
let mut valid = true;
|
let mut valid = true;
|
||||||
for _ in 0..256 {
|
for _ in 0..256 {
|
||||||
|
@ -340,26 +343,23 @@ mod ddr {
|
||||||
}
|
}
|
||||||
|
|
||||||
if valid {
|
if valid {
|
||||||
last_valid = delay;
|
if !have_min_delay {
|
||||||
if which {
|
min_delay = delay;
|
||||||
break;
|
have_min_delay = true;
|
||||||
}
|
}
|
||||||
|
max_delay = delay;
|
||||||
}
|
}
|
||||||
ddrphy::rdly_dq_inc_write(1);
|
ddrphy::rdly_dq_inc_write(1);
|
||||||
}
|
}
|
||||||
last_valid
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find smallest working delay
|
let mean_delay = (min_delay + max_delay) / 2;
|
||||||
let min_delay = find_edge(true);
|
log!(logger, "{}: {} ({} wide), ",
|
||||||
let max_delay = find_edge(false);
|
DQS_SIGNAL_COUNT - n - 1, mean_delay,
|
||||||
|
max_delay - min_delay);
|
||||||
log!(logger, "{}:{:02}-{:02} ", DQS_SIGNAL_COUNT - n - 1,
|
|
||||||
min_delay, max_delay);
|
|
||||||
|
|
||||||
// Set delay to the middle
|
// Set delay to the middle
|
||||||
ddrphy::rdly_dq_rst_write(1);
|
ddrphy::rdly_dq_rst_write(1);
|
||||||
for _ in 0..(min_delay + max_delay) / 2 {
|
for _ in 0..mean_delay {
|
||||||
ddrphy::rdly_dq_inc_write(1);
|
ddrphy::rdly_dq_inc_write(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue