Skip to content

Commit 5c08423

Browse files
committedMay 8, 2015
dds: support batches in driver
1 parent b22b8b6 commit 5c08423

File tree

4 files changed

+64
-15
lines changed

4 files changed

+64
-15
lines changed
 

‎artiq/coredevice/dds.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@
1010
PHASE_MODE_TRACKING = 2
1111

1212

13+
class DDSBus(AutoDB):
14+
"""Core device Direct Digital Synthesis (DDS) bus batching driver.
15+
16+
Manages batching of DDS commands on a DDS shared bus."""
17+
class DBKeys:
18+
core = Device()
19+
20+
@kernel
21+
def batch_enter(self):
22+
"""Starts a DDS command batch. All DDS commands are buffered
23+
after this call, until ``batch_exit`` is called."""
24+
syscall("dds_batch_enter", time_to_cycles(now()))
25+
26+
@kernel
27+
def batch_exit(self):
28+
"""Ends a DDS command batch. All buffered DDS commands are issued
29+
on the bus, and FUD is pulsed at the time the batch started."""
30+
syscall("dds_batch_exit")
31+
32+
1333
class DDS(AutoDB):
1434
"""Core device Direct Digital Synthesis (DDS) driver.
1535
16-
Controls DDS devices managed directly by the core device's runtime.
36+
Controls one DDS channel managed directly by the core device's runtime.
1737
1838
:param dds_sysclk: DDS system frequency, used for computing the frequency
1939
tuning words.
@@ -43,7 +63,7 @@ def ftw_to_frequency(self, ftw):
4363

4464
@kernel
4565
def init(self):
46-
"""Resets and initializes the DDS."""
66+
"""Resets and initializes the DDS channel."""
4767
syscall("dds_init", time_to_cycles(now()), self.channel)
4868

4969
@kernel

‎examples/master/ddb.pyon

+10-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
"arguments": {"channel": 18}
5151
},
5252

53+
"dds_bus": {
54+
"type": "local",
55+
"module": "artiq.coredevice.dds",
56+
"class": "DDSBus",
57+
"arguments": {}
58+
},
5359
"dds0": {
5460
"type": "local",
5561
"module": "artiq.coredevice.dds",
@@ -123,6 +129,8 @@
123129
},
124130

125131
"pmt": "pmt0",
126-
"bd": "dds0",
127-
"bdd": "dds1"
132+
"bd_dds": "dds0",
133+
"bd_sw": "ttl0",
134+
"bdd_dds": "dds1",
135+
"bdd_sw": "ttl1"
128136
}

‎examples/master/repository/dds_test.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class DDSTest(Experiment, AutoDB):
66

77
class DBKeys:
88
core = Device()
9+
dds_bus = Device()
910
dds0 = Device()
1011
dds1 = Device()
1112
dds2 = Device()
@@ -16,9 +17,10 @@ class DBKeys:
1617

1718
@kernel
1819
def run(self):
19-
# with dds_batch:
20-
# self.dds1.set(120*MHz)
21-
# self.dds2.set(200*MHz)
20+
self.dds_bus.batch_enter()
21+
self.dds1.set(120*MHz)
22+
self.dds2.set(200*MHz)
23+
self.dds_bus.batch_exit()
2224

2325
for i in range(10000):
2426
if i & 0x200:

‎examples/master/repository/photon_histogram.py

+27-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ class PhotonHistogram(Experiment, AutoDB):
66

77
class DBKeys:
88
core = Device()
9-
bd = Device()
10-
bdd = Device()
9+
dds_bus = Device()
10+
bd_dds = Device()
11+
bd_sw = Device()
12+
bdd_dds = Device()
13+
bdd_sw = Device()
1114
pmt = Device()
1215

1316
nbins = Argument(100)
@@ -22,21 +25,37 @@ class DBKeys:
2225
hist = Result()
2326
total = Result()
2427

28+
@kernel
29+
def program_cooling(self):
30+
self.dds_bus.batch_enter()
31+
self.bd_dds.set(200*MHz)
32+
self.bdd_dds.set(300*MHz)
33+
self.dds_bus.batch_exit()
34+
2535
@kernel
2636
def cool_detect(self):
2737
with parallel:
28-
self.bd.pulse(200*MHz, 1*ms)
29-
self.bdd.pulse(300*MHz, 1*ms)
30-
self.bd.pulse(self.cool_f, 100*us)
38+
self.bd_sw.pulse(1*ms)
39+
self.bdd_sw.pulse(1*ms)
40+
41+
self.bd_dds.set(self.cool_f)
42+
self.bd_sw.pulse(100*us)
43+
44+
self.bd_dds.set(self.detect_f)
3145
with parallel:
32-
self.bd.pulse(self.detect_f, self.detect_t)
46+
self.bd_sw.pulse(self.detect_t)
3347
self.pmt.gate_rising(self.detect_t)
34-
self.bd.on(200*MHz)
35-
self.bdd.on(300*MHz)
48+
49+
self.program_cooling()
50+
self.bd_sw.on()
51+
self.bdd_sw.on()
52+
3653
return self.pmt.count()
3754

3855
@kernel
3956
def run(self):
57+
self.program_cooling()
58+
4059
hist = [0 for _ in range(self.nbins)]
4160
total = 0
4261

0 commit comments

Comments
 (0)
Please sign in to comment.