2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

dds: support batches in driver

This commit is contained in:
Sebastien Bourdeauducq 2015-05-08 22:17:06 +08:00
parent b22b8b661b
commit 5c08423b29
4 changed files with 64 additions and 15 deletions

View File

@ -10,10 +10,30 @@ PHASE_MODE_ABSOLUTE = 1
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 @@ class DDS(AutoDB):
@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

View File

@ -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"
}

View File

@ -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 DDSTest(Experiment, AutoDB):
@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:

View File

@ -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 PhotonHistogram(Experiment, AutoDB):
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