forked from M-Labs/artiq
fixes
This commit is contained in:
parent
25c0dc4688
commit
0df2cadcd3
@ -1288,8 +1288,7 @@ class Miqro:
|
|||||||
def write8(self, addr, data):
|
def write8(self, addr, data):
|
||||||
self.channel.phaser.write16(PHASER_ADDR_MIQRO_ADDR,
|
self.channel.phaser.write16(PHASER_ADDR_MIQRO_ADDR,
|
||||||
(self.channel.index << 13) | addr)
|
(self.channel.index << 13) | addr)
|
||||||
self.channel.phaser.write8(PHASER_ADDR_MIQRO_DATA,
|
self.channel.phaser.write8(PHASER_ADDR_MIQRO_DATA, data)
|
||||||
data)
|
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def write32(self, addr, data):
|
def write32(self, addr, data):
|
||||||
@ -1298,16 +1297,24 @@ class Miqro:
|
|||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def set_frequency_mu(self, oscillator, profile, ftw):
|
def set_frequency_mu(self, oscillator, profile, ftw):
|
||||||
|
if oscillator >= 16:
|
||||||
|
raise ValueError("invalid oscillator index")
|
||||||
|
if profile >= 32:
|
||||||
|
raise ValueError("invalid profile index")
|
||||||
self.write32((1 << 12) | (oscillator << 8) | (profile << 3), ftw)
|
self.write32((1 << 12) | (oscillator << 8) | (profile << 3), ftw)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def set_amplitude_phase_mu(self, oscillator, profile, asf, pow=0):
|
def set_amplitude_phase_mu(self, oscillator, profile, asf, pow=0):
|
||||||
|
if oscillator >= 16:
|
||||||
|
raise ValueError("invalid oscillator index")
|
||||||
|
if profile >= 32:
|
||||||
|
raise ValueError("invalid profile index")
|
||||||
self.write32((1 << 12) | (oscillator << 8) | (profile << 3) | (1 << 2),
|
self.write32((1 << 12) | (oscillator << 8) | (profile << 3) | (1 << 2),
|
||||||
(asf & 0xffff) | (pow << 16))
|
(asf & 0xffff) | (pow << 16))
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def set_window(self, start, data, rate=1, shift=0, order=3, head=1, tail=1):
|
def set_window(self, start, data, rate=1, shift=0, order=0, head=1, tail=1):
|
||||||
if len(data) == 0 or len(data) >= (1 << 10):
|
if len(data) >= 1 << 10:
|
||||||
raise ValueError("invalid window length")
|
raise ValueError("invalid window length")
|
||||||
if rate < 1 or rate > 1 << 12:
|
if rate < 1 or rate > 1 << 12:
|
||||||
raise ValueError("rate out of bounds")
|
raise ValueError("rate out of bounds")
|
||||||
@ -1315,10 +1322,10 @@ class Miqro:
|
|||||||
self.write32(addr,
|
self.write32(addr,
|
||||||
((start + 1 + len(data)) & 0x3ff)
|
((start + 1 + len(data)) & 0x3ff)
|
||||||
| ((rate - 1) << 10)
|
| ((rate - 1) << 10)
|
||||||
| (shift << 22)
|
| ((shift & 0x3f) << 22)
|
||||||
| (order << 28)
|
| ((order & 3) << 28)
|
||||||
| (head << 30)
|
| ((head & 1) << 30)
|
||||||
| (tail << 31)
|
| ((tail & 1) << 31)
|
||||||
)
|
)
|
||||||
for i in range(len(data)):
|
for i in range(len(data)):
|
||||||
addr += 4
|
addr += 4
|
||||||
@ -1326,6 +1333,10 @@ class Miqro:
|
|||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def pulse(self, window, profiles):
|
def pulse(self, window, profiles):
|
||||||
|
if len(profiles) > 16:
|
||||||
|
raise ValueError("too many oscillators")
|
||||||
|
if window > 0x3ff:
|
||||||
|
raise ValueError("invalid window")
|
||||||
data = [window, 0, 0]
|
data = [window, 0, 0]
|
||||||
word = 0
|
word = 0
|
||||||
idx = 10
|
idx = 10
|
||||||
@ -1333,7 +1344,7 @@ class Miqro:
|
|||||||
if idx >= 30:
|
if idx >= 30:
|
||||||
word += 1
|
word += 1
|
||||||
idx = 0
|
idx = 0
|
||||||
data[word] |= profiles[i] << (idx * 5)
|
data[word] |= (profiles[i] & 0x1f) << idx
|
||||||
idx += 5
|
idx += 5
|
||||||
while word >= 0:
|
while word >= 0:
|
||||||
rtio_output(self.base_addr + word, data[word])
|
rtio_output(self.base_addr + word, data[word])
|
||||||
|
@ -100,11 +100,16 @@ class MiqroChannel(Module):
|
|||||||
regs = [Signal(30, reset_less=True) for _ in range(3)]
|
regs = [Signal(30, reset_less=True) for _ in range(3)]
|
||||||
dt = Signal(7, reset_less=True)
|
dt = Signal(7, reset_less=True)
|
||||||
stb = Signal()
|
stb = Signal()
|
||||||
self.comb += self.pulse.eq(Cat(stb, dt, regs))
|
pulse = Cat(stb, dt, regs)
|
||||||
|
assert len(self.pulse) >= len(pulse)
|
||||||
|
self.comb += [
|
||||||
|
self.pulse.eq(pulse),
|
||||||
|
self.rtlink.o.busy.eq(stb & ~self.ack),
|
||||||
|
]
|
||||||
self.sync.rtio += [
|
self.sync.rtio += [
|
||||||
dt.eq(dt + 2),
|
dt.eq(dt + 2),
|
||||||
If(self.ack,
|
If(self.ack,
|
||||||
dt.eq(0),
|
dt[1:].eq(0),
|
||||||
stb.eq(0),
|
stb.eq(0),
|
||||||
),
|
),
|
||||||
If(self.rtlink.o.stb,
|
If(self.rtlink.o.stb,
|
||||||
|
Loading…
Reference in New Issue
Block a user