From bf1a3a5b8f8664d44b58507b1b9331a34d09655a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 24 Dec 2015 19:25:29 +0800 Subject: [PATCH] test/coredevice: add analyzer unittest --- artiq/test/coredevice/analyzer.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 artiq/test/coredevice/analyzer.py diff --git a/artiq/test/coredevice/analyzer.py b/artiq/test/coredevice/analyzer.py new file mode 100644 index 000000000..fa062f022 --- /dev/null +++ b/artiq/test/coredevice/analyzer.py @@ -0,0 +1,30 @@ +from artiq.language import * +from artiq.coredevice.analyzer import decode_dump, OutputMessage +from artiq.test.hardware_testbench import ExperimentCase + + +class CreateTTLPulse(EnvExperiment): + def build(self): + self.setattr_device("core") + self.setattr_device("ttl_out") + + @kernel + def run(self): + self.ttl_out.pulse_mu(1000) + + +class AnalyzerTest(ExperimentCase): + def test_ttl_pulse(self): + comm = self.device_mgr.get("comm") + + # clear analyzer buffer + comm.get_analyzer_dump() + + exp = self.create(CreateTTLPulse) + exp.run() + + dump = decode_dump(comm.get_analyzer_dump()) + ttl_messages = [msg for msg in dump.messages if isinstance(msg, OutputMessage)] + self.assertEqual(len(ttl_messages), 2) + self.assertEqual(abs(ttl_messages[0].timestamp - ttl_messages[1].timestamp), 1000) +