Merge pull request #421 from betrusted-io/clk0_fractional

add fractional division options to clk0 config on PLL
This commit is contained in:
enjoy-digital 2020-03-13 14:15:24 +01:00 committed by GitHub
commit f34593a17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -53,6 +53,7 @@ def compute_config_log(logger, config):
class XilinxClocking(Module, AutoCSR): class XilinxClocking(Module, AutoCSR):
clkfbout_mult_frange = (2, 64+1) clkfbout_mult_frange = (2, 64+1)
clkout_divide_range = (1, 128+1) clkout_divide_range = (1, 128+1)
clkout0_divide_range = (2, (128+0.125), 0.125)
def __init__(self, vco_margin=0): def __init__(self, vco_margin=0):
self.vco_margin = vco_margin self.vco_margin = vco_margin
@ -122,6 +123,19 @@ class XilinxClocking(Module, AutoCSR):
config["clkout{}_phase".format(n)] = p config["clkout{}_phase".format(n)] = p
valid = True valid = True
break break
if not valid and n == 0:
# clkout0 supports fractional division, try the fractional range as a fallback
(start, stop, step) = self.clkout0_divide_range
d = start
while d < stop:
clk_freq = vco_freq / d
if abs(clk_freq - f) <= f * m:
config["clkout{}_freq".format(n)] = clk_freq
config["clkout{}_divide".format(n)] = d
config["clkout{}_phase".format(n)] = p
valid = True
break
d += step
if not valid: if not valid:
all_valid = False all_valid = False
else: else: