From eebff6d77f4e89c7077a39204353bab460a573e0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 28 Jan 2019 18:38:18 +0800 Subject: [PATCH] jesd204sync: fix max_phase_deviation --- artiq/firmware/libboard_artiq/jesd204sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artiq/firmware/libboard_artiq/jesd204sync.rs b/artiq/firmware/libboard_artiq/jesd204sync.rs index 075656d76..3959e7ccd 100644 --- a/artiq/firmware/libboard_artiq/jesd204sync.rs +++ b/artiq/firmware/libboard_artiq/jesd204sync.rs @@ -164,7 +164,7 @@ fn measure_sysref_sh_limits() -> Result { fn max_phase_deviation(average: i32, phases: &[i32]) -> i32 { let mut ret = 0; for phase in phases.iter() { - let deviation = (phase - average).abs(); + let deviation = (phase - average + DDMTD_N) % DDMTD_N; if deviation > ret { ret = deviation; }