forked from M-Labs/artiq
test: add test for short RTIO input gate
Based on https://github.com/m-labs/artiq/pull/1136 See also https://github.com/m-labs/artiq/issues/1137
This commit is contained in:
parent
12a1a8ee97
commit
c83e22c11c
@ -178,6 +178,61 @@ class LoopbackCount(EnvExperiment):
|
|||||||
self.set_dataset("count", self.loop_in.count())
|
self.set_dataset("count", self.loop_in.count())
|
||||||
|
|
||||||
|
|
||||||
|
class IncorrectPulseTiming(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LoopbackGateTiming(EnvExperiment):
|
||||||
|
def build(self):
|
||||||
|
self.setattr_device("core")
|
||||||
|
self.setattr_device("loop_in")
|
||||||
|
self.setattr_device("loop_out")
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def run(self):
|
||||||
|
# Make sure there are no leftover events.
|
||||||
|
self.core.reset()
|
||||||
|
|
||||||
|
# Determine loop delay.
|
||||||
|
with parallel:
|
||||||
|
self.loop_in.gate_rising_mu(10000)
|
||||||
|
with sequential:
|
||||||
|
delay_mu(5000)
|
||||||
|
out_mu = now_mu()
|
||||||
|
self.loop_out.pulse_mu(1000)
|
||||||
|
in_mu = self.loop_in.timestamp_mu()
|
||||||
|
if in_mu < 0:
|
||||||
|
raise PulseNotReceived("Cannot determine loop delay")
|
||||||
|
loop_delay_mu = in_mu - out_mu
|
||||||
|
|
||||||
|
# With the exact delay known, make sure tight gate timings work.
|
||||||
|
# In the most common configuration, 24 mu == 24 ns == 3 coarse periods,
|
||||||
|
# which should be plenty of slack.
|
||||||
|
delay_mu(10000)
|
||||||
|
|
||||||
|
gate_start_mu = now_mu()
|
||||||
|
self.loop_in.gate_both_mu(24)
|
||||||
|
gate_end_mu = now_mu()
|
||||||
|
|
||||||
|
# gateware latency offset between gate and input
|
||||||
|
lat_offset = 3*8
|
||||||
|
out_mu = gate_start_mu - loop_delay_mu + lat_offset
|
||||||
|
at_mu(out_mu)
|
||||||
|
self.loop_out.pulse_mu(24)
|
||||||
|
|
||||||
|
in_mu = self.loop_in.timestamp_mu()
|
||||||
|
if in_mu < 0:
|
||||||
|
raise PulseNotReceived()
|
||||||
|
if not (gate_start_mu <= (in_mu - lat_offset) <= gate_end_mu):
|
||||||
|
raise IncorrectPulseTiming("Input event should occur during gate")
|
||||||
|
if not (-2 < (in_mu - out_mu - loop_delay_mu) < 2):
|
||||||
|
raise IncorrectPulseTiming("Loop delay should not change")
|
||||||
|
|
||||||
|
in_mu = self.loop_in.timestamp_mu()
|
||||||
|
if in_mu > 0:
|
||||||
|
raise IncorrectPulseTiming("Only one pulse should be received")
|
||||||
|
|
||||||
|
|
||||||
class IncorrectLevel(Exception):
|
class IncorrectLevel(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -387,6 +442,9 @@ class CoredeviceTest(ExperimentCase):
|
|||||||
count = self.dataset_mgr.get("count")
|
count = self.dataset_mgr.get("count")
|
||||||
self.assertEqual(count, npulses)
|
self.assertEqual(count, npulses)
|
||||||
|
|
||||||
|
def test_loopback_gate_timing(self):
|
||||||
|
self.execute(LoopbackGateTiming)
|
||||||
|
|
||||||
def test_level(self):
|
def test_level(self):
|
||||||
self.execute(Level)
|
self.execute(Level)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user