forked from M-Labs/artiq
dds: support batches in driver
This commit is contained in:
parent
b22b8b661b
commit
5c08423b29
|
@ -10,10 +10,30 @@ PHASE_MODE_ABSOLUTE = 1
|
||||||
PHASE_MODE_TRACKING = 2
|
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):
|
class DDS(AutoDB):
|
||||||
"""Core device Direct Digital Synthesis (DDS) driver.
|
"""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
|
:param dds_sysclk: DDS system frequency, used for computing the frequency
|
||||||
tuning words.
|
tuning words.
|
||||||
|
@ -43,7 +63,7 @@ class DDS(AutoDB):
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def init(self):
|
def init(self):
|
||||||
"""Resets and initializes the DDS."""
|
"""Resets and initializes the DDS channel."""
|
||||||
syscall("dds_init", time_to_cycles(now()), self.channel)
|
syscall("dds_init", time_to_cycles(now()), self.channel)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
|
|
|
@ -50,6 +50,12 @@
|
||||||
"arguments": {"channel": 18}
|
"arguments": {"channel": 18}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"dds_bus": {
|
||||||
|
"type": "local",
|
||||||
|
"module": "artiq.coredevice.dds",
|
||||||
|
"class": "DDSBus",
|
||||||
|
"arguments": {}
|
||||||
|
},
|
||||||
"dds0": {
|
"dds0": {
|
||||||
"type": "local",
|
"type": "local",
|
||||||
"module": "artiq.coredevice.dds",
|
"module": "artiq.coredevice.dds",
|
||||||
|
@ -123,6 +129,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"pmt": "pmt0",
|
"pmt": "pmt0",
|
||||||
"bd": "dds0",
|
"bd_dds": "dds0",
|
||||||
"bdd": "dds1"
|
"bd_sw": "ttl0",
|
||||||
|
"bdd_dds": "dds1",
|
||||||
|
"bdd_sw": "ttl1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ class DDSTest(Experiment, AutoDB):
|
||||||
|
|
||||||
class DBKeys:
|
class DBKeys:
|
||||||
core = Device()
|
core = Device()
|
||||||
|
dds_bus = Device()
|
||||||
dds0 = Device()
|
dds0 = Device()
|
||||||
dds1 = Device()
|
dds1 = Device()
|
||||||
dds2 = Device()
|
dds2 = Device()
|
||||||
|
@ -16,9 +17,10 @@ class DDSTest(Experiment, AutoDB):
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self):
|
||||||
# with dds_batch:
|
self.dds_bus.batch_enter()
|
||||||
# self.dds1.set(120*MHz)
|
self.dds1.set(120*MHz)
|
||||||
# self.dds2.set(200*MHz)
|
self.dds2.set(200*MHz)
|
||||||
|
self.dds_bus.batch_exit()
|
||||||
|
|
||||||
for i in range(10000):
|
for i in range(10000):
|
||||||
if i & 0x200:
|
if i & 0x200:
|
||||||
|
|
|
@ -6,8 +6,11 @@ class PhotonHistogram(Experiment, AutoDB):
|
||||||
|
|
||||||
class DBKeys:
|
class DBKeys:
|
||||||
core = Device()
|
core = Device()
|
||||||
bd = Device()
|
dds_bus = Device()
|
||||||
bdd = Device()
|
bd_dds = Device()
|
||||||
|
bd_sw = Device()
|
||||||
|
bdd_dds = Device()
|
||||||
|
bdd_sw = Device()
|
||||||
pmt = Device()
|
pmt = Device()
|
||||||
|
|
||||||
nbins = Argument(100)
|
nbins = Argument(100)
|
||||||
|
@ -22,21 +25,37 @@ class PhotonHistogram(Experiment, AutoDB):
|
||||||
hist = Result()
|
hist = Result()
|
||||||
total = 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
|
@kernel
|
||||||
def cool_detect(self):
|
def cool_detect(self):
|
||||||
with parallel:
|
with parallel:
|
||||||
self.bd.pulse(200*MHz, 1*ms)
|
self.bd_sw.pulse(1*ms)
|
||||||
self.bdd.pulse(300*MHz, 1*ms)
|
self.bdd_sw.pulse(1*ms)
|
||||||
self.bd.pulse(self.cool_f, 100*us)
|
|
||||||
|
self.bd_dds.set(self.cool_f)
|
||||||
|
self.bd_sw.pulse(100*us)
|
||||||
|
|
||||||
|
self.bd_dds.set(self.detect_f)
|
||||||
with parallel:
|
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.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()
|
return self.pmt.count()
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self):
|
||||||
|
self.program_cooling()
|
||||||
|
|
||||||
hist = [0 for _ in range(self.nbins)]
|
hist = [0 for _ in range(self.nbins)]
|
||||||
total = 0
|
total = 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue