From e504262b67e6f3774f15ad9443d83a05789ef793 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 13 Mar 2019 15:36:05 +0800 Subject: [PATCH] kasli_tester: calibrate Urukul synchronization and write to EEPROM --- .../kasli_basic/repository/kasli_tester.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/artiq/examples/kasli_basic/repository/kasli_tester.py b/artiq/examples/kasli_basic/repository/kasli_tester.py index 4acdecd73..37f14c67e 100644 --- a/artiq/examples/kasli_basic/repository/kasli_tester.py +++ b/artiq/examples/kasli_basic/repository/kasli_tester.py @@ -184,6 +184,14 @@ class KasliTester(EnvExperiment): self.core.break_realtime() cpld.init() + @kernel + def calibrate_urukul(self, channel): + self.core.break_realtime() + sync_delay_seed, _ = channel.tune_sync_delay() + self.core.break_realtime() + io_update_delay = channel.tune_io_update_delay() + return sync_delay_seed, io_update_delay + @kernel def setup_urukul(self, channel, frequency): self.core.break_realtime() @@ -214,6 +222,23 @@ class KasliTester(EnvExperiment): self.init_urukul(cpld) print("...done") + print("Calibrating inter-device synchronization...") + for channel_name, channel_dev in self.urukuls: + if channel_dev.sync_delay_seed_eeprom is None and channel_dev.io_update_delay_eeprom is None: + print("{}\tno synchronization".format(channel_name)) + elif channel_dev.sync_delay_seed_eeprom is not channel_dev.io_update_delay_eeprom: + print("{}\tunsupported EEPROM configuration".format(channel_name)) + elif channel_dev.sync_delay_seed_offset != channel_dev.io_update_delay_offset: + print("{}\tunsupported EEPROM offsets".format(channel_name)) + else: + eeprom = channel_dev.sync_delay_seed_eeprom + offset = channel_dev.sync_delay_seed_offset + sync_delay_seed, io_update_delay = self.calibrate_urukul(channel_dev) + print("{}\t{} {}".format(channel_name, sync_delay_seed, io_update_delay)) + eeprom_word = (sync_delay_seed << 24) | (io_update_delay << 16) + eeprom.write_i32(offset, eeprom_word) + print("...done") + print("Frequencies:") for card_n, channels in enumerate(chunker(self.urukuls, 4)): for channel_n, (channel_name, channel_dev) in enumerate(channels):