From 5e994071ce3c738b20824fec95a40f3d2f76db42 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 14 Oct 2014 15:54:28 +0800 Subject: [PATCH] examples: add RTIO skew --- examples/rtio_skew.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/rtio_skew.py diff --git a/examples/rtio_skew.py b/examples/rtio_skew.py new file mode 100644 index 000000000..f408190c6 --- /dev/null +++ b/examples/rtio_skew.py @@ -0,0 +1,36 @@ +from artiq import * +from artiq.devices import corecom_serial, core, rtio_core + + +def print_skew(p): + print("Input/output skew: {} ns".format(p)) + + +def print_failed(): + print("Pulse was not received back") + + +class RTIOSkew(AutoContext): + parameters = "i o" + + @kernel + def run(self): + with parallel: + self.i.gate_rising(10*us) + with sequential: + delay(5*us) + out_t = now() + self.o.pulse(5*us) + in_t = self.i.timestamp() + if in_t < 0*s: + print_failed() + else: + print_skew(int((out_t - in_t)/(1*ns))) + +if __name__ == "__main__": + with corecom_serial.CoreCom() as com: + coredev = core.Core(com) + exp = RTIOSkew(core=coredev, + i=rtio_core.RTIOIn(core=coredev, channel=0), + o=rtio_core.RTIOOut(core=coredev, channel=1)) + exp.run()