Skip to content
Snippets Groups Projects
readPLLRegister.py 1.48 KiB
"""
   readPLLRegister.py -- module to read external PLLs registers via i2c

   Author
    PR: First version

"""
import time
import os
import pathtocomponents
import sys


from fpga_comp import Arria10
from si534x_comp import Si534x
from xcvr_comp import xcvr


def main():
   if (len(sys.argv) != 2):
      print "Missing argument"
      print "Syntax : config_PLLs <Nb_of_card> where Nb_of_pcie_slot"
      exit()
   elif (sys.argv[1] == "0"):
      print
      print "===== Target board = 0"
      dev = 0
   elif (sys.argv[1] == "2"):
      print
      print "===== Target board = 2"
      dev = 2
   else:
      print "Wrong argument"
      print "Syntax : config_PLLs <Nb_of_card> where Nb_of_pcie_slot = 0 or 2"
      exit()

   # Program PLLs
   devices = \
       {1: "SI5345_U23",
        2: "SI5345_U48",
        3: "SI5344_U54"
        }
   ports = \
       {1: [0, 1, 2, 3],
        2: [0, 1, 3, 4, 8],
        3: [0, 1]
        }
        
   #dev = 0  # Creates a list of objects with the 3 PLLs
   add = 0x68
   pll = [Si534x(dev, bus, add) for bus in devices.keys()]
   print
   
   for i in devices.keys():  # programs the 3 PLLs
      print "-----------------------------------------------"
      status, val = pll[i-1].read_part_number()
      print "..... Type of chip =", format(val,'x')
      status, val = pll[i-1].read_device_revision()
      print "..... Revision =", val

   print "-----------------------------------------------"


   # Measure clocks


if __name__ == "__main__":
    main()