Skip to content

Commit

Permalink
test/coredevice: add analyzer unittest
Browse files Browse the repository at this point in the history
sbourdeauducq committed Dec 24, 2015
1 parent 5f3b69d commit bf1a3a5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions artiq/test/coredevice/analyzer.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bf1a3a5

Please sign in to comment.