From 9b43f09c1dcb0aa3556a83908f8339776e6434b5 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Fri, 14 Oct 2016 11:56:10 +0200 Subject: [PATCH] phaser: cleanup prbs --- artiq/examples/phaser/repository/dac_setup.py | 2 +- .../phaser/repository/test_ad9154_prbs.py | 29 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/artiq/examples/phaser/repository/dac_setup.py b/artiq/examples/phaser/repository/dac_setup.py index 974a8c9aa..3a1693ecb 100644 --- a/artiq/examples/phaser/repository/dac_setup.py +++ b/artiq/examples/phaser/repository/dac_setup.py @@ -62,7 +62,7 @@ class DACSetup(EnvExperiment): @kernel def busywait_us(self, t): - t = now_mu() + seconds_to_mu(t*us) + t = self.core.get_rtio_counter_mu() + seconds_to_mu(t*us) while self.core.get_rtio_counter_mu() < t: pass diff --git a/artiq/examples/phaser/repository/test_ad9154_prbs.py b/artiq/examples/phaser/repository/test_ad9154_prbs.py index 337da468f..c5aedcb2c 100644 --- a/artiq/examples/phaser/repository/test_ad9154_prbs.py +++ b/artiq/examples/phaser/repository/test_ad9154_prbs.py @@ -1,5 +1,3 @@ -import time - from artiq.coredevice.ad9154_reg import * from artiq.experiment import * @@ -9,14 +7,25 @@ class Test(EnvExperiment): self.setattr_device("core") self.setattr_device("ad9154") + @kernel def run(self): - for i in range(3): # prbs7, prbs15, prbs31 - self.prbs(i, 100) + for e in range(2): + for i in range(3): # prbs7, prbs15, prbs31 + self.prbs(i, 10, e) + + @kernel + def busywait_us(self, t): + t = self.core.get_rtio_counter_mu() + seconds_to_mu(t*us) + while self.core.get_rtio_counter_mu() < t: + pass def p(self, f, *a): - print(f % a) + print(f.format(*a)) - def prbs(self, p, t, inject_errors=0): + @kernel + def prbs(self, p, t, inject_errors): + self.p("---\nprbs sequence {}, threshold {}, inject_errors {}:", + p, t, inject_errors) self.ad9154.jesd_prbs((1 << p) | (inject_errors << 3)) self.ad9154.dac_write(AD9154_PHY_PRBS_TEST_CTRL, @@ -35,15 +44,17 @@ class Test(EnvExperiment): self.ad9154.dac_write(AD9154_PHY_PRBS_TEST_CTRL, AD9154_PHY_PRBS_PAT_SEL_SET(p) | AD9154_PHY_TEST_START_SET(1)) - time.sleep(.5) + self.busywait_us(1000000) self.ad9154.dac_write(AD9154_PHY_PRBS_TEST_CTRL, AD9154_PHY_PRBS_PAT_SEL_SET(p)) - self.p("prbs status: 0x%02x", self.ad9154.dac_read(AD9154_PHY_PRBS_TEST_STATUS)) + self.p("prbs status: {:#04x}", self.ad9154.dac_read(AD9154_PHY_PRBS_TEST_STATUS)) for i in range(8): self.ad9154.dac_write(AD9154_PHY_PRBS_TEST_CTRL, AD9154_PHY_SRC_ERR_CNT_SET(i)) - self.p("prbs errors[%d]: 0x%08x", i, + self.p("prbs errors[{}]: {:#08x}", i, self.ad9154.dac_read(AD9154_PHY_PRBS_TEST_ERRCNT_LOBITS) | (self.ad9154.dac_read(AD9154_PHY_PRBS_TEST_ERRCNT_MIDBITS) << 8) | (self.ad9154.dac_read(AD9154_PHY_PRBS_TEST_ERRCNT_HIBITS) << 16)) + + self.ad9154.jesd_prbs(0)