pdq2: small improvements based on ML feedback

This commit is contained in:
Sebastien Bourdeauducq 2014-10-22 17:31:33 +08:00
parent b96249339d
commit 85b6a7ca24
2 changed files with 20 additions and 10 deletions

View File

@ -3,11 +3,10 @@ from artiq.language.units import *
from artiq.coredevice import rtio from artiq.coredevice import rtio
# FIXME: check those numbers
frame_setup = 20*ns frame_setup = 20*ns
trigger_duration = 100*ns trigger_duration = 50*ns
frame_wait = 100*ns frame_wait = 20*ns
sample_period = 10*us sample_period = 10*us # FIXME: check this
class SegmentSequenceError(Exception): class SegmentSequenceError(Exception):
@ -50,13 +49,19 @@ class _Frame:
self.segment_count = 0 self.segment_count = 0
self.closed = False self.closed = False
def append(self, name, t, u, trigger=False): def append(self, t, u, trigger=False, name=None):
if self.closed: if self.closed:
raise FrameCloseError raise FrameCloseError
sn = self.segment_count sn = self.segment_count
duration = (t[-1] - t[0])*sample_period duration = (t[-1] - t[0])*sample_period
segment = _Segment(self, sn, duration, (t, u, trigger)) segment = _Segment(self, sn, duration, (t, u, trigger))
setattr(self, name, segment) if name is None:
# TODO
raise NotImplementedError("Anonymous segments are not supported yet")
else:
if hasattr(self, name):
raise NameError("Segment name already exists")
setattr(self, name, segment)
self.segment_count += 1 self.segment_count += 1
def close(self): def close(self):
@ -80,6 +85,11 @@ class _Frame:
self.pdq.trigger.on(t) self.pdq.trigger.on(t)
self.pdq.trigger.off(t + time_to_cycles(trigger_duration)) self.pdq.trigger.off(t + time_to_cycles(trigger_duration))
@kernel
def advance(self):
# TODO
raise NotImplementedError
@kernel @kernel
def finish(self): def finish(self):
if self.pdq.current_frame != self.fn: if self.pdq.current_frame != self.fn:

View File

@ -22,12 +22,12 @@ class Transport(AutoContext):
# stores duration and the fact that this segment needs to be triggered # stores duration and the fact that this segment needs to be triggered
# both (duration and segment triggering flag) to be retrieved during # both (duration and segment triggering flag) to be retrieved during
# kernel compilation, see transport() # kernel compilation, see transport()
self.tf.append("to_stop", self.tf.append(t, u, trigger=True,
t, u, trigger=True) name="to_stop")
# append the reverse transport (from stop to 0) # append the reverse transport (from stop to 0)
# both durations are the same in this case # both durations are the same in this case
self.tf.append("from_stop", self.tf.append(t[-1] - t[::-1], u[::-1], trigger=True,
t[-1] - t[::-1], u[::-1], trigger=True) name="from_stop")
# closes the frame with a wait line before jumping back into # closes the frame with a wait line before jumping back into
# the jump table so that frame signal can be set before the jump # the jump table so that frame signal can be set before the jump
# also mark the frame as closed and prevent further append()ing # also mark the frame as closed and prevent further append()ing