From 3e84ec2bf1d32e063dd22f59f65aef62a24c9911 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 12 Jan 2019 00:43:15 +0000 Subject: [PATCH] coredevice.ad9910: Fix phase tracking ref_time passing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is difficult to test without hardware mocks or some form of phase readback, but the symptom was that e.g. `self.dds.set(…, ref_time=now_mu() - 1)` would fail periodically, that is, whenever bit 32 of the timestamp would be set (which would be turned into the sign bit). This is a fairly sinister issue, and is probably a compiler bug of some sort (either accepts-invalid or wrong type inference). --- artiq/coredevice/ad9910.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/artiq/coredevice/ad9910.py b/artiq/coredevice/ad9910.py index 37e48723f..6b5717655 100644 --- a/artiq/coredevice/ad9910.py +++ b/artiq/coredevice/ad9910.py @@ -371,9 +371,11 @@ class AD9910: self.set_cfr1(power_down=bits) self.cpld.io_update.pulse(1*us) + # KLUDGE: ref_time default argument is explicitly marked int64() to avoid + # silent truncation of explicitly passed timestamps. (Compiler bug?) @kernel def set_mu(self, ftw, pow_=0, asf=0x3fff, phase_mode=_PHASE_MODE_DEFAULT, - ref_time=-1, profile=0): + ref_time=int64(-1), profile=0): """Set profile 0 data in machine units. This uses machine units (FTW, POW, ASF). The frequency tuning word @@ -514,7 +516,7 @@ class AD9910: @kernel def set(self, frequency, phase=0.0, amplitude=1.0, - phase_mode=_PHASE_MODE_DEFAULT, ref_time=-1, profile=0): + phase_mode=_PHASE_MODE_DEFAULT, ref_time=int64(-1), profile=0): """Set profile 0 data in SI units. .. seealso:: :meth:`set_mu`