diff --git a/basil/HL/MIO_PLL.py b/basil/HL/MIO_PLL.py index bdc336937..3fe2c79f1 100644 --- a/basil/HL/MIO_PLL.py +++ b/basil/HL/MIO_PLL.py @@ -5,7 +5,6 @@ # ------------------------------------------------------------ # -from __future__ import division import logging from basil.HL.HardwareLayer import HardwareLayer @@ -125,13 +124,13 @@ def _calculateParameters(self, fout): ''' for self.q_counter in range(128): self.q_total = self.q_counter + 2 - if (self.fref // self.q_total) < 0.25: # PLL constraint + if (self.fref / self.q_total) < 0.25: # PLL constraint break for self.div in range(2, 128): q_d_f = self.q_total * self.div * fout if isinstance(q_d_f, (long, int)) and q_d_f > (15 * self.fref): # = f0 * p if int(q_d_f) % int(self.fref) == 0: # p, q, and d found - self.p_total = q_d_f // self.fref + self.p_total = q_d_f / self.fref while self.p_total <= 16: # counter constraint self.p_total = self.p_total * 2 self.div = self.div * 2 @@ -139,13 +138,13 @@ def _calculateParameters(self, fout): break if self.p_total > 1023: break - if ((self.fref * self.p_total // self.q_total) < 100 or (self.fref * self.p_total // self.q_total) > 400): # PLL constraint + if ((self.fref * self.p_total / self.q_total) < 100 or (self.fref * self.p_total / self.q_total) > 400): # PLL constraint break if int(self.p_total) % 2 == 0: self.p_0 = 0 else: self.p_0 = 1 - self.p_counter = ((int(self.p_total) - self.p_0) // 2) - 4 # set p counter value + self.p_counter = ((int(self.p_total) - self.p_0) / 2) - 4 # set p counter value if self.div == 2: self.clk1SRC = 0x02 @@ -172,8 +171,8 @@ def _calculateParameters(self, fout): else: if self.p_total <= 1023: self.chg_pump = 4 - ftest = self.fref * self.p_total // self.q_total * 1 // self.div - fvco = self.fref * self.p_total // self.q_total + ftest = self.fref * self.p_total / self.q_total * 1 / self.div + fvco = self.fref * self.p_total / self.q_total logger.info('PLL frequency set to ' + str(ftest) + ' MHz' + ' (VCO @ ' + str(fvco) + ' MHz)') return True logger.error('MIO_PLL: Could not find PLL parameters')