forked from M-Labs/artiq
1
0
Fork 0

jesd204sync: print DDMTD SYSREF final alignment delta

This commit is contained in:
Sebastien Bourdeauducq 2019-01-28 18:39:16 +08:00
parent eebff6d77f
commit 1a42e23fb4
1 changed files with 9 additions and 12 deletions

View File

@ -172,18 +172,15 @@ fn max_phase_deviation(average: i32, phases: &[i32]) -> i32 {
return ret; return ret;
} }
fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<(), &'static str> { fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<i32, &'static str> {
let mut phase = measure_ddmdt_phase(); for _ in 0..1024 {
let mut nslips = 0; let delta = (measure_ddmdt_phase() - target + DDMTD_N) % DDMTD_N;
while (phase - target).abs() > tolerance { if delta <= tolerance {
hmc7043::sysref_slip(); return Ok(delta)
nslips += 1;
if nslips > 1024 {
return Err("failed to reach SYSREF DDMTD phase target");
} }
phase = measure_ddmdt_phase(); hmc7043::sysref_slip();
} }
Ok(()) Err("failed to reach SYSREF DDMTD phase target")
} }
fn calibrate_sysref_target(rising_average: i32, falling_average: i32) -> Result<i32, &'static str> { fn calibrate_sysref_target(rising_average: i32, falling_average: i32) -> Result<i32, &'static str> {
@ -275,11 +272,11 @@ pub fn sysref_auto_rtio_align() -> Result<(), &'static str> {
}; };
info!("aligning SYSREF with RTIO clock..."); info!("aligning SYSREF with RTIO clock...");
reach_sysref_ddmtd_target(target_phase, 3)?; let delta = reach_sysref_ddmtd_target(target_phase, 3)?;
if sysref_sh_error() { if sysref_sh_error() {
return Err("SYSREF does not meet S/H timing at DDMTD phase target"); return Err("SYSREF does not meet S/H timing at DDMTD phase target");
} }
info!(" ...done"); info!(" ...done, delta={}", delta);
sysref_rtio_align()?; sysref_rtio_align()?;