Skip to content

Commit

Permalink
gateware/dds/monitor: support onehot selection, strip reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Aug 27, 2015
1 parent 0fe0f4d commit 90ce54d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions artiq/gateware/rtio/phy/dds.py
Expand Up @@ -5,7 +5,7 @@


class _AD9xxx(Module):
def __init__(self, ftw_base, pads, nchannels, **kwargs):
def __init__(self, ftw_base, pads, nchannels, onehot=False, **kwargs):
self.submodules._ll = RenameClockDomains(
ad9xxx.AD9xxx(pads, **kwargs), "rio")
self.submodules._rt2wb = RT2WB(flen(pads.a)+1, self._ll.bus)
Expand All @@ -21,23 +21,29 @@ def __init__(self, ftw_base, pads, nchannels, **kwargs):
current_address.eq(self.rtlink.o.address),
current_data.eq(self.rtlink.o.data))

# keep track of the currently selected channel
current_channel = Signal(max=nchannels)
# keep track of the currently selected channel(s)
current_sel = Signal(flen(current_data)-1)
self.sync.rio += If(current_address == 2**flen(pads.a) + 1,
current_channel.eq(current_data))
current_sel.eq(current_data[1:])) # strip reset

def selected(c):
if onehot:
return current_sel[c]
else:
return current_sel == c

# keep track of frequency tuning words, before they are FUDed
ftws = [Signal(32) for i in range(nchannels)]
for c, ftw in enumerate(ftws):
if flen(pads.d) == 8:
self.sync.rio += \
If(current_channel == c, [
If(selected(c), [
If(current_address == ftw_base+i,
ftw[i*8:(i+1)*8].eq(current_data))
for i in range(4)])
elif flen(pads.d) == 16:
self.sync.rio += \
If(current_channel == c, [
If(selected(c), [
If(current_address == ftw_base+2*i,
ftw[i*16:(i+1)*16].eq(current_data))
for i in range(2)])
Expand All @@ -46,15 +52,15 @@ def __init__(self, ftw_base, pads, nchannels, **kwargs):

# FTW to probe on FUD
self.sync.rio += If(current_address == 2**flen(pads.a), [
If(current_channel == c, probe.eq(ftw))
If(selected(c), probe.eq(ftw))
for c, (probe, ftw) in enumerate(zip(self.probes, ftws))])


class AD9858(_AD9xxx):
def __init__(self, pads, nchannels, **kwargs):
_AD9xxx.__init__(self, 0x0a, pads, nchannels, **kwargs)
def __init__(self, *args, **kwargs):
_AD9xxx.__init__(self, 0x0a, *args, **kwargs)


class AD9914(_AD9xxx):
def __init__(self, pads, nchannels, **kwargs):
_AD9xxx.__init__(self, 0x2d, pads, nchannels, **kwargs)
def __init__(self, *args, **kwargs):
_AD9xxx.__init__(self, 0x2d, *args, **kwargs)
2 changes: 1 addition & 1 deletion soc/targets/artiq_kc705.py
Expand Up @@ -206,7 +206,7 @@ def __init__(self, platform, cpu_type="or1k", **kwargs):
self.add_constant("DDS_CHANNEL_COUNT", 11)
self.add_constant("DDS_AD9914")
self.add_constant("DDS_ONEHOT_SEL")
phy = dds.AD9914(platform.request("dds"), 11)
phy = dds.AD9914(platform.request("dds"), 11, onehot=True)
self.submodules += phy
rtio_channels.append(rtio.Channel.from_phy(phy,
ofifo_depth=512,
Expand Down

0 comments on commit 90ce54d

Please sign in to comment.