From a4997c56cfe8670bc26cff6c136ffcfab59c1a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 9 Nov 2018 18:54:34 +0000 Subject: [PATCH] ad9910: simplify edge detection logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Jördens --- artiq/coredevice/ad9910.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/artiq/coredevice/ad9910.py b/artiq/coredevice/ad9910.py index a37f48705..ff5954874 100644 --- a/artiq/coredevice/ad9910.py +++ b/artiq/coredevice/ad9910.py @@ -536,13 +536,12 @@ class AD9910: for j in range(repeat): t1[0] += self.measure_io_update_alignment(i, i + 1) t1[1] += self.measure_io_update_alignment(i + 1, i + 2) - if ((t1[0] == 0 and t1[1] == repeat) or # edge left of i + 1 - (t1[0] == repeat and t1[1] == 0) or # edge right of i + 1 - (t1[0] != 0 and t1[1] != 0 and # edge very close to i + 1 - t1[0] != repeat and t1[1] != repeat)): - # the good delay is period//2 after the edge - return (i + 1 + period//2) & (period - 1) - else: # can't interpret result + if ((t1[0] == 0 and t1[1] == 0) or + (t1[0] == repeat and t1[1] == repeat)): + # edge is not close to i + 1, can't interpret result raise ValueError( "no clear IO_UPDATE-SYNC_CLK alignment edge found") + else: + # the good delay is period//2 after the edge + return (i + 1 + period//2) & (period - 1) raise ValueError("no IO_UPDATE-SYNC_CLK alignment edge found")