forked from M-Labs/artiq
1
0
Fork 0

ad9912: support configurable clk_div

This commit is contained in:
Robert Jördens 2019-01-18 12:06:33 +00:00
parent 2bea5e3d58
commit 385916a9a4
1 changed files with 8 additions and 8 deletions

View File

@ -21,11 +21,11 @@ class AD9912:
:param sw_device: Name of the RF switch device. The RF switch is a :param sw_device: Name of the RF switch device. The RF switch is a
TTLOut channel available as the :attr:`sw` attribute of this instance. TTLOut channel available as the :attr:`sw` attribute of this instance.
:param pll_n: DDS PLL multiplier. The DDS sample clock is :param pll_n: DDS PLL multiplier. The DDS sample clock is
f_ref*pll_n where f_ref is the reference frequency (set in the parent f_ref/clk_div*pll_n where f_ref is the reference frequency and clk_div
Urukul CPLD instance). is the reference clock divider (both set in the parent Urukul CPLD
instance).
""" """
kernel_invariants = {"chip_select", "cpld", "core", "bus", kernel_invariants = {"chip_select", "cpld", "core", "bus", "ftw_per_hz"}
"ftw_per_hz", "sysclk", "pll_n"}
def __init__(self, dmgr, chip_select, cpld_device, sw_device=None, def __init__(self, dmgr, chip_select, cpld_device, sw_device=None,
pll_n=10): pll_n=10):
@ -38,9 +38,9 @@ class AD9912:
self.sw = dmgr.get(sw_device) self.sw = dmgr.get(sw_device)
self.kernel_invariants.add("sw") self.kernel_invariants.add("sw")
self.pll_n = pll_n self.pll_n = pll_n
self.sysclk = self.cpld.refclk*pll_n sysclk = self.cpld.refclk/[1, 1, 2, 4][self.cpld.clk_div]*pll_n
assert self.sysclk <= 1e9 assert sysclk <= 1e9
self.ftw_per_hz = 1/self.sysclk*(int64(1) << 48) self.ftw_per_hz = 1/sysclk*(int64(1) << 48)
@kernel @kernel
def write(self, addr, data, length): def write(self, addr, data, length):