Skip to content

Commit

Permalink
dds: support batches in driver
Browse files Browse the repository at this point in the history
sbourdeauducq committed May 8, 2015
1 parent b22b8b6 commit 5c08423
Showing 4 changed files with 64 additions and 15 deletions.
24 changes: 22 additions & 2 deletions artiq/coredevice/dds.py
Original file line number Diff line number Diff line change
@@ -10,10 +10,30 @@
PHASE_MODE_TRACKING = 2


class DDSBus(AutoDB):
"""Core device Direct Digital Synthesis (DDS) bus batching driver.
Manages batching of DDS commands on a DDS shared bus."""
class DBKeys:
core = Device()

@kernel
def batch_enter(self):
"""Starts a DDS command batch. All DDS commands are buffered
after this call, until ``batch_exit`` is called."""
syscall("dds_batch_enter", time_to_cycles(now()))

@kernel
def batch_exit(self):
"""Ends a DDS command batch. All buffered DDS commands are issued
on the bus, and FUD is pulsed at the time the batch started."""
syscall("dds_batch_exit")


class DDS(AutoDB):
"""Core device Direct Digital Synthesis (DDS) driver.
Controls DDS devices managed directly by the core device's runtime.
Controls one DDS channel managed directly by the core device's runtime.
:param dds_sysclk: DDS system frequency, used for computing the frequency
tuning words.
@@ -43,7 +63,7 @@ def ftw_to_frequency(self, ftw):

@kernel
def init(self):
"""Resets and initializes the DDS."""
"""Resets and initializes the DDS channel."""
syscall("dds_init", time_to_cycles(now()), self.channel)

@kernel
12 changes: 10 additions & 2 deletions examples/master/ddb.pyon
Original file line number Diff line number Diff line change
@@ -50,6 +50,12 @@
"arguments": {"channel": 18}
},

"dds_bus": {
"type": "local",
"module": "artiq.coredevice.dds",
"class": "DDSBus",
"arguments": {}
},
"dds0": {
"type": "local",
"module": "artiq.coredevice.dds",
@@ -123,6 +129,8 @@
},

"pmt": "pmt0",
"bd": "dds0",
"bdd": "dds1"
"bd_dds": "dds0",
"bd_sw": "ttl0",
"bdd_dds": "dds1",
"bdd_sw": "ttl1"
}
8 changes: 5 additions & 3 deletions examples/master/repository/dds_test.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ class DDSTest(Experiment, AutoDB):

class DBKeys:
core = Device()
dds_bus = Device()
dds0 = Device()
dds1 = Device()
dds2 = Device()
@@ -16,9 +17,10 @@ class DBKeys:

@kernel
def run(self):
# with dds_batch:
# self.dds1.set(120*MHz)
# self.dds2.set(200*MHz)
self.dds_bus.batch_enter()
self.dds1.set(120*MHz)
self.dds2.set(200*MHz)
self.dds_bus.batch_exit()

for i in range(10000):
if i & 0x200:
35 changes: 27 additions & 8 deletions examples/master/repository/photon_histogram.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,11 @@ class PhotonHistogram(Experiment, AutoDB):

class DBKeys:
core = Device()
bd = Device()
bdd = Device()
dds_bus = Device()
bd_dds = Device()
bd_sw = Device()
bdd_dds = Device()
bdd_sw = Device()
pmt = Device()

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

@kernel
def program_cooling(self):
self.dds_bus.batch_enter()
self.bd_dds.set(200*MHz)
self.bdd_dds.set(300*MHz)
self.dds_bus.batch_exit()

@kernel
def cool_detect(self):
with parallel:
self.bd.pulse(200*MHz, 1*ms)
self.bdd.pulse(300*MHz, 1*ms)
self.bd.pulse(self.cool_f, 100*us)
self.bd_sw.pulse(1*ms)
self.bdd_sw.pulse(1*ms)

self.bd_dds.set(self.cool_f)
self.bd_sw.pulse(100*us)

self.bd_dds.set(self.detect_f)
with parallel:
self.bd.pulse(self.detect_f, self.detect_t)
self.bd_sw.pulse(self.detect_t)
self.pmt.gate_rising(self.detect_t)
self.bd.on(200*MHz)
self.bdd.on(300*MHz)

self.program_cooling()
self.bd_sw.on()
self.bdd_sw.on()

return self.pmt.count()

@kernel
def run(self):
self.program_cooling()

hist = [0 for _ in range(self.nbins)]
total = 0

0 comments on commit 5c08423

Please sign in to comment.