forked from M-Labs/artiq
1
0
Fork 0

miqro format change: encode len, not end

This commit is contained in:
Robert Jördens 2022-09-15 11:02:59 +00:00
parent af28bf3550
commit 14ab1d4bbc
1 changed files with 10 additions and 8 deletions

View File

@ -1386,8 +1386,8 @@ class Miqro:
for osc in range(16): for osc in range(16):
for pro in range(32): for pro in range(32):
self.set_profile_mu(osc, pro, 0, 0, 0) self.set_profile_mu(osc, pro, 0, 0, 0)
delay(20*us) delay(10*us)
self.set_window_mu(start=0, iq=[0], rate=1, shift=0, order=0, head=0, tail=1) self.set_window_mu(start=0, iq=[0], rate=1, shift=0, order=0, head=0, tail=0)
self.pulse(window=0, profiles=[0]) self.pulse(window=0, profiles=[0])
@kernel @kernel
@ -1412,6 +1412,7 @@ class Miqro:
raise ValueError("amplitude out of bounds") raise ValueError("amplitude out of bounds")
pow = int32(round(phase*(1 << 16))) pow = int32(round(phase*(1 << 16)))
self.set_profile_mu(oscillator, profile, ftw, asf, pow) self.set_profile_mu(oscillator, profile, ftw, asf, pow)
return ftw
@kernel @kernel
def set_window_mu(self, start, iq, rate=1, shift=0, order=3, head=1, tail=1): def set_window_mu(self, start, iq, rate=1, shift=0, order=3, head=1, tail=1):
@ -1428,7 +1429,7 @@ class Miqro:
self.channel.phaser.write16(PHASER_ADDR_MIQRO_MEM_ADDR, self.channel.phaser.write16(PHASER_ADDR_MIQRO_MEM_ADDR,
(self.channel.index << 15) | start) (self.channel.index << 15) | start)
self.channel.phaser.write32(PHASER_ADDR_MIQRO_MEM_DATA, self.channel.phaser.write32(PHASER_ADDR_MIQRO_MEM_DATA,
((start + 1 + len(iq)) & 0x3ff) | (len(iq) & 0x3ff) |
((rate - 1) << 10) | ((rate - 1) << 10) |
(shift << 22) | (shift << 22) |
(order << 28) | (order << 28) |
@ -1457,6 +1458,7 @@ class Miqro:
for iqi in iq for iqi in iq
] ]
self.set_window_mu(start, iq_mu, rate, shift, order, head, tail) self.set_window_mu(start, iq_mu, rate, shift, order, head, tail)
return rate
@kernel @kernel
def encode(self, window, profiles, data): def encode(self, window, profiles, data):
@ -1470,20 +1472,20 @@ class Miqro:
for profile in profiles: for profile in profiles:
if profile > 0x1f: if profile > 0x1f:
raise ValueError("profile out of bounds") raise ValueError("profile out of bounds")
if idx >= 30:
word += 1
idx = 0
data[word] |= profile << idx data[word] |= profile << idx
idx += 5 idx += 5
return word + 1 if idx > 32 - 5:
word += 1
idx = 0
return word
@kernel @kernel
def pulse_mu(self, data): def pulse_mu(self, data):
word = len(data) word = len(data)
delay_mu(-8*word) # back shift to align delay_mu(-8*word) # back shift to align
while word > 0: while word > 0:
delay_mu(8)
word -= 1 word -= 1
delay_mu(8)
# final write sets pulse stb # final write sets pulse stb
rtio_output(self.base_addr + word, data[word]) rtio_output(self.base_addr + word, data[word])