-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/coredevice: add analyzer unittest
1 parent
5f3b69d
commit bf1a3a5
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|