forked from M-Labs/artiq
1
0
Fork 0

sawg: merge set/set64

This commit is contained in:
Robert Jördens 2016-12-01 16:25:01 +01:00
parent 93a853a0e0
commit 6e9bc7c05d
2 changed files with 13 additions and 19 deletions

View File

@ -36,23 +36,18 @@ class Spline:
""" """
rtio_output(now_mu(), self.channel, 0, value) rtio_output(now_mu(), self.channel, 0, value)
@kernel @kernel(flags={"fast-math"})
def set(self, value: TFloat): def set(self, value: TFloat):
"""Set spline value. """Set spline value.
:param value: Spline value relative to full-scale. :param value: Spline value relative to full-scale.
""" """
rtio_output(now_mu(), self.channel, 0, self.to_mu(value)) if self.width > 32:
l = [int32(0)] * 2
@kernel(flags={"fast-math"}) self.pack_coeff_mu([self.to_mu64(value)], l)
def set64(self, value: TFloat): rtio_output_wide(now_mu(), self.channel, 0, l)
"""Set spline value. else:
rtio_output(now_mu(), self.channel, 0, self.to_mu(value))
:param value: Spline value relative to full-scale.
"""
l = [int32(0)] * 2
self.pack_coeff_mu([self.to_mu64(value)], l)
rtio_output_wide(now_mu(), self.channel, 0, l)
@kernel @kernel
def set_coeff_mu(self, value): # TList(TInt32) def set_coeff_mu(self, value): # TList(TInt32)

View File

@ -55,8 +55,8 @@ class SAWGTest(unittest.TestCase):
d = self.driver d = self.driver
d.offset.set(.9) d.offset.set(.9)
delay(2*self.t) delay(2*self.t)
d.frequency0.set64(.1) d.frequency0.set(.1)
d.frequency1.set64(.1) d.frequency1.set(.1)
delay(2*self.t) delay(2*self.t)
d.offset.set(0) d.offset.set(0)
v = int(round((1 << 48) * .1 * self.t)) v = int(round((1 << 48) * .1 * self.t))
@ -64,10 +64,9 @@ class SAWGTest(unittest.TestCase):
self.rtio_manager.outputs, [ self.rtio_manager.outputs, [
(0., 1, 0, int(round( (0., 1, 0, int(round(
(1 << self.driver.offset.width - 1)*.9))), (1 << self.driver.offset.width - 1)*.9))),
(2.*self.t, 8, 0, [int(round( (2.*self.t, 8, 0, int(round(
(1 << self.driver.frequency0.width) * (1 << self.driver.frequency0.width) *
self.t/self.channel.parallelism*.1)), self.t/self.channel.parallelism*.1))),
0]),
(2.*self.t, 3, 0, [int32(v), int32(v >> 32)]), (2.*self.t, 3, 0, [int32(v), int32(v >> 32)]),
(4.*self.t, 1, 0, 0), (4.*self.t, 1, 0, 0),
]) ])
@ -200,9 +199,9 @@ class SAWGTest(unittest.TestCase):
self.sawg0.frequency0.set(10*MHz) self.sawg0.frequency0.set(10*MHz)
self.sawg0.phase0.set(0.) self.sawg0.phase0.set(0.)
self.sawg0.frequency1.set64(1*MHz) self.sawg0.frequency1.set(1*MHz)
self.sawg0.phase1.set(0.) self.sawg0.phase1.set(0.)
self.sawg0.frequency2.set64(13*MHz) self.sawg0.frequency2.set(13*MHz)
self.sawg0.phase2.set(0.) self.sawg0.phase2.set(0.)
t = now_mu() t = now_mu()
self.sawg0.amplitude1.smooth(.0, a1, t_up, order) self.sawg0.amplitude1.smooth(.0, a1, t_up, order)