PLL REFDIV values > 1 considered by vcocalc.py (#952)
This commit is contained in:
parent
3ed9e2fb1e
commit
24bb3627cf
@ -4,6 +4,7 @@ import argparse
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description="PLL parameter calculator")
|
parser = argparse.ArgumentParser(description="PLL parameter calculator")
|
||||||
parser.add_argument("--input", "-i", default=12, help="Input (reference) frequency. Default 12 MHz", type=float)
|
parser.add_argument("--input", "-i", default=12, help="Input (reference) frequency. Default 12 MHz", type=float)
|
||||||
|
parser.add_argument("--ref-min", default=5, help="Override minimum reference frequency. Default 5 MHz", type=float)
|
||||||
parser.add_argument("--vco-max", default=1600, help="Override maximum VCO frequency. Default 1600 MHz", type=float)
|
parser.add_argument("--vco-max", default=1600, help="Override maximum VCO frequency. Default 1600 MHz", type=float)
|
||||||
parser.add_argument("--vco-min", default=750, help="Override minimum VCO frequency. Default 750 MHz", type=float)
|
parser.add_argument("--vco-min", default=750, help="Override minimum VCO frequency. Default 750 MHz", type=float)
|
||||||
parser.add_argument("--low-vco", "-l", action="store_true", help="Use a lower VCO frequency when possible. This reduces power consumption, at the cost of increased jitter")
|
parser.add_argument("--low-vco", "-l", action="store_true", help="Use a lower VCO frequency when possible. This reduces power consumption, at the cost of increased jitter")
|
||||||
@ -13,12 +14,18 @@ args = parser.parse_args()
|
|||||||
# Fixed hardware parameters
|
# Fixed hardware parameters
|
||||||
fbdiv_range = range(16, 320 + 1)
|
fbdiv_range = range(16, 320 + 1)
|
||||||
postdiv_range = range(1, 7 + 1)
|
postdiv_range = range(1, 7 + 1)
|
||||||
|
ref_min = 5
|
||||||
|
refdiv_min = 1
|
||||||
|
refdiv_max = 63
|
||||||
|
|
||||||
best = (0, 0, 0, 0)
|
refdiv_range = range(refdiv_min, max(refdiv_min, min(refdiv_max, int(args.input / args.ref_min))) + 1)
|
||||||
|
|
||||||
|
best = (0, 0, 0, 0, 0)
|
||||||
best_margin = args.output
|
best_margin = args.output
|
||||||
|
|
||||||
for fbdiv in (fbdiv_range if args.low_vco else reversed(fbdiv_range)):
|
for refdiv in refdiv_range:
|
||||||
vco = args.input * fbdiv
|
for fbdiv in (fbdiv_range if args.low_vco else reversed(fbdiv_range)):
|
||||||
|
vco = args.input / refdiv * fbdiv
|
||||||
if vco < args.vco_min or vco > args.vco_max:
|
if vco < args.vco_min or vco > args.vco_max:
|
||||||
continue
|
continue
|
||||||
# pd1 is inner loop so that we prefer higher ratios of pd1:pd2
|
# pd1 is inner loop so that we prefer higher ratios of pd1:pd2
|
||||||
@ -27,11 +34,12 @@ for fbdiv in (fbdiv_range if args.low_vco else reversed(fbdiv_range)):
|
|||||||
out = vco / pd1 / pd2
|
out = vco / pd1 / pd2
|
||||||
margin = abs(out - args.output)
|
margin = abs(out - args.output)
|
||||||
if margin < best_margin:
|
if margin < best_margin:
|
||||||
best = (out, fbdiv, pd1, pd2)
|
best = (out, fbdiv, pd1, pd2, refdiv)
|
||||||
best_margin = margin
|
best_margin = margin
|
||||||
|
|
||||||
print("Requested: {} MHz".format(args.output))
|
print("Requested: {} MHz".format(args.output))
|
||||||
print("Achieved: {} MHz".format(best[0]))
|
print("Achieved: {} MHz".format(best[0]))
|
||||||
print("FBDIV: {} (VCO = {} MHz)".format(best[1], args.input * best[1]))
|
print("REFDIV: {}".format(best[4]))
|
||||||
|
print("FBDIV: {} (VCO = {} MHz)".format(best[1], args.input / best[4] * best[1]))
|
||||||
print("PD1: {}".format(best[2]))
|
print("PD1: {}".format(best[2]))
|
||||||
print("PD2: {}".format(best[3]))
|
print("PD2: {}".format(best[3]))
|
||||||
|
Loading…
Reference in New Issue
Block a user