def InitializeDevice(self): # Open the first device we find. self.xem = ok.okCFrontPanel() if (self.xem.NoError != self.xem.OpenBySerial("")): print ("A device could not be opened. Is one connected?") return(False) # Get some general information about the device. self.devInfo = ok.okTDeviceInfo() if (self.xem.NoError != self.xem.GetDeviceInfo(self.devInfo)): print ("Unable to retrieve device information.") return(False) print(" Product: " + self.devInfo.productName) print("Firmware version: %d.%d" % (self.devInfo.deviceMajorVersion, self.devInfo.deviceMinorVersion)) print(" Serial Number: %s" % self.devInfo.serialNumber) print(" Device ID: %s" % self.devInfo.deviceID) # Download the configuration file. if (self.xem.NoError != self.xem.ConfigureFPGA("ok_XLA.bit")): print ("FPGA configuration failed.") return(False) # Check for FrontPanel support in the FPGA configuration. if (False == self.xem.IsFrontPanelEnabled()): print ("FrontPanel support is not available.") return(False) print ("FrontPanel support is available.") return(True)
def initFPGA(dev, bitfile): # Open and configure the FPGA, then reset the HDL design devInfo = ok.okTDeviceInfo() dev.GetDeviceInfo(devInfo) print("Found a device: " + devInfo.productName) print("Device firmware version: " + str(devInfo.deviceMajorVersion) + "." + str(devInfo.deviceMinorVersion)) print("Device serial number: " + devInfo.serialNumber) print("Device ID: " + str(devInfo.productID)) print("Configuring FPGA...") if (ok.okCFrontPanel.NoError != dev.ConfigureFPGA(bitfile)): print("FPGA configuration failed.") return False if (dev.IsFrontPanelEnabled()): print("FrontPanel support is enabled") else: print("FrontPanel support is not enabled") return False # Toggle reset dev.SetWireInValue(0x00, 0x1, 0x1) dev.UpdateWireIns() dev.SetWireInValue(0x00, 0x0, 0x1) dev.UpdateWireIns() return True
def InitializeDevice(self): # Open the first device we find. self.xem = ok.okCFrontPanel() if (self.xem.NoError != self.xem.OpenBySerial("")): print("[INITIAL]", "A device could not be opened. Is one connected?") return(False) # Get some general information about the device. self.devInfo = ok.okTDeviceInfo() if (self.xem.NoError != self.xem.GetDeviceInfo(self.devInfo)): print("[INITIAL]", "Unable to retrieve device information.") return(False) print("[INITIAL]", " Product: ", self.devInfo.productName) print("[INITIAL]", "Firmware version: %d.%d" % (self.devInfo.deviceMajorVersion, self.devInfo.deviceMinorVersion)) print("[INITIAL]", " Serial Number: %s" % self.devInfo.serialNumber) print("[INITIAL]", " Device ID: %s" % self.devInfo.deviceID) self.xem.LoadDefaultPLLConfiguration() # Download the configuration file. if (self.xem.NoError != self.xem.ConfigureFPGA(bit_directory)): print("[INITIAL]", "FPGA configuration failed.") return(False) # Check for FrontPanel support in the FPGA configuration. if (False == self.xem.IsFrontPanelEnabled()): print("[INITIAL]", "FrontPanel support is not available.") return(False) print("[INITIAL]", "FrontPanel support is available.") return(True)
def InitializeDevice(self): # Open the first device we find. self.dev = ok.okCFrontPanel() self.pll = ok.okCPLL22150() if (self.dev.NoError != self.dev.OpenBySerial("")): print("A device could not be opened. Is one connected?") return(False) # Get some general information about the device. self.devInfo = ok.okTDeviceInfo() if (self.dev.NoError != self.dev.GetDeviceInfo(self.devInfo)): print("Unable to retrieve device information.") return(False) print(" Product: {}".format(self.devInfo.productName)) print("Firmware version: {}.{}".format(self.devInfo.deviceMajorVersion, self.devInfo.deviceMinorVersion)) print(" Serial Number: {}".format(self.devInfo.serialNumber)) print(" Device ID: {}".format(self.devInfo.deviceID.split('\0')[0])) self.dev.LoadDefaultPLLConfiguration() # Download the configuration file. if self.ConfigFile == '': if self.devInfo.productName == 'XEM6002-LX9': self.ConfigFile = r'..\okwmb-xem6002.bit' if (self.dev.NoError != self.dev.ConfigureFPGA(self.ConfigFile)): return(False) # Check for FrontPanel support in the FPGA configuration. if (False == self.dev.IsFrontPanelEnabled()): return(False) # Initialisation completed successfully return(True)
def initializeDevice(self): # Open the first device we find. if self.xem.NoError != self.xem.OpenBySerial(""): raise RuntimeError("A device could not be opened. Is one connected, or in use by another process?") # Get some general information about the device. self.devInfo = ok.okTDeviceInfo() if self.xem.NoError != self.xem.GetDeviceInfo(self.devInfo): print("Unable to retrieve device information.") return False print(" Product: " + self.devInfo.productName) print("Firmware version: %d.%d" % (self.devInfo.deviceMajorVersion, self.devInfo.deviceMinorVersion)) print(" Serial Number: %s" % self.devInfo.serialNumber) print(" Device ID: %s" % self.devInfo.deviceID) self.xem.LoadDefaultPLLConfiguration() # Download the configuration file. if self.xem.NoError != self.xem.ConfigureFPGA("main.bit"): print("FPGA configuration failed.") return False # Check for FrontPanel support in the FPGA configuration. if not self.xem.IsFrontPanelEnabled(): print("FrontPanel support is not available.") return False print("FrontPanel support is available.") self.resetBuffer() return True
def __init__(self): self.xem = ok.okCFrontPanel() if (self.xem.NoError != self.xem.OpenBySerial("")): print ("A device could not be opened. Is one connected?") #return(False) devInfo = ok.okTDeviceInfo() if (self.xem.NoError != self.xem.GetDeviceInfo(devInfo)): print ("Unable to retrieve device information.") exit print("Got device: " + devInfo.productName) if (self.xem.NoError != self.xem.ConfigureFPGA("cavity.bit")): print ("FPGA configuration failed.") exit
def bootprofile(dev, devInfo): # print "This function is not fully implemented, yet..." # return bootprofile = raw_input("Type in the filename.\n") sec = raw_input("Are you sure you want to set", bootprofile, "as the new boot profile? (y/n)") if sec == 'n': return m_devInfo = ok.okTDeviceInfo() # if dev.OpenBySerial("") != dev.NoError: # print "Device could not be opened.\nLeaving..." # return if (dev.NoError != dev.GetDeviceInfo(devInfo)): print("Error: Unable to retrieve device information.") return if dev.IsFrontPanelEnabled(): print "Starting the boot profile reset..." else: print "FrontPanel is not enabled.\nConsider resetting the FPGA." return dev.GetDeviceInfo(m_devInfo) print "sectorcount and sectorsize:", m_devInfo.flashFPGA.sectorCount, m_devInfo.flashFPGA.sectorSize return print "Deleting the present boot profile." oldprofile memset(oldprofile, 0, sizeof(okTFPGAResetProfile)) dev.SetFPGAResetProfile(ok_FPGAConfigurationMethod_NVRAM, oldprofile) if m_devInfo.flashFPGA.sectorCount == 0: print "This device does not have an appropriate FPGA Flash." return else: print "Available Flash: %d Mib\n", m_devInfo.flashFPGA.sectorCount * m_devInfo.flashFPGA.sectorSize * 8 / 1024 / 1024
def InitializeDevice(self): print("---- Opal Kelly ---- PipeTest Application vX.Y ----\n"); # Open the first device we find. self.xem = ok.okCFrontPanel() if (self.xem.NoError != self.xem.OpenBySerial("")): print("A device could not be opened. Is one connected?") return(False) # Get some general information about the device. self.devInfo = ok.okTDeviceInfo() if (self.xem.NoError != self.xem.GetDeviceInfo(self.devInfo)): print("Unable to retrieve device information.") return(False) print(" Product: {}".format(self.devInfo.productName)) print("Firmware version: {}.{}".format(self.devInfo.deviceMajorVersion, self.devInfo.deviceMinorVersion)) print(" Serial Number: {}".format(self.devInfo.serialNumber)) print(" Device ID: {}".format(self.devInfo.deviceID.split('\0')[0])) self.xem.LoadDefaultPLLConfiguration() # Download the configuration file. if self.devInfo.productName == 'XEM6002-LX9': config_file_name = '..\pipetest-xem6002.bit' else: config_file_name = '' if (self.xem.NoError != self.xem.ConfigureFPGA(config_file_name)): print("FPGA configuration failed.") return(False) # Check for FrontPanel support in the FPGA configuration. if (False == self.xem.IsFrontPanelEnabled()): print("FrontPanel support is not available.") return(False) print("FrontPanel support is available.") # Initialisation completed successfully return(True)
done = 'y' os.close(fd) if __name__ == "__main__": memsize = 4095 mem = numpy.zeros([256, memsize], dtype=numpy.int) # for i in range(256): # for o in range(memsize): # mem[i][o] = 1 filename = 'finalv3_3.rbf' dev = ok.okCFrontPanel() devInfo = ok.okTDeviceInfo() print "\n--------------------------------------------" print " Welcome to the EHR testing program!" print "___|" u"\u203e" "|___|" u"\u203e" "|_|" u"\u203e" "|_|" u"\u203e" "|_|" u"\u203e" "|___|" u"\u203e" "|_|" u"\u203e" "" u"\u203e" "" u"\u203e" "|_|" u"\u203e" "|____" print "--------------------------------------------\n" accesserror = 0 #Commented for debug mode if dev.OpenBySerial("") != dev.NoError: print "Device could not be opened.\nConsider leaving..." accesserror += 1 if (dev.NoError != dev.GetDeviceInfo(devInfo)): print("Error: Unable to retrieve device information.") accesserror += 1 print("Found Device: " + devInfo.productName)
def __init__(self,serial = "",filename = "",max_modulus = 100, verbose = False): #Initialisation resets (->0) the pattern memory up to max_modulus. #It is recommended not to reconfigure the FPGA unless it is necessary. #The FPGA will only be reconfigured if filename != "". #The default design is assumed at "./rbfiles/finalv3_1_top.rbf" #It will be used if the FrontPanel interface does not react at the first attempt. print "\n---- Initialising the EHR ----\n" if max_modulus < 0 or max_modulus >= 4096: print "Invalid value for max_modulus. It is set to 4095." self.memsize = 4095 else: self.memsize = max_modulus self.mem = numpy.zeros([256,self.memsize],dtype=numpy.int) self.select = numpy.ones([256,2],dtype=numpy.int) self.dev = ok.okCFrontPanel() self.devInfo = ok.okTDeviceInfo() if self.dev.OpenBySerial(serial) != self.dev.NoError: print "Device could not be opened.\nLeaving..." sys.exit(1) if (self.dev.NoError != self.dev.GetDeviceInfo(self.devInfo)): print "Error: Unable to retrieve device information." sys.exit(1) print("Found Device: " + self.devInfo.productName) print("Device ID: %s" % self.devInfo.deviceID) if filename != "": print "Found configuration file: ",filename if self.configureFPGA(filename) == False: print "Unable to configure FPGA." sys.exit(1) else: filename = "./rbfiles/finalv3_1_top.rbf" #Checking for FrontPanel (USB communication) support for i in range(1,7): if self.dev.IsFrontPanelEnabled(): print "FrontPanel is enabled." break elif i == 6: print "Failed to enable FrontPanel. Leaving..." sys.exit(1) else: print "FrontPanel disabled. Reconfiguring...",i self.dev.ConfigureFPGA(filename) if self.reset_pll() == False: print "PLL could not be resetted!" sys.exit(1) #Initialise mem to all 0 print "Initialising memory...", self.mem_data_init = 0 self.mem_addr_init = 0 self.dev.SetWireInValue(0x05,self.mem_data_init) for bit in range(self.memsize): for addr in range(8): self.mem_addr_init = int(((addr + (bit*8)) *2) +1) self.dev.SetWireInValue(0x04,self.mem_addr_init) self.dev.UpdateWireIns() self.dev.SetWireInValue(0x04,0) self.dev.UpdateWireIns() #Initialise select to all 1 self.sel_data_init = 0xffffffff self.sel_addr_init = 0 self.dev.SetWireInValue(0x03,self.sel_data_init) for addr in range(16): self.sel_addr_init = (addr*4)+2 self.dev.SetWireInValue(0x02,self.sel_addr_init) self.dev.UpdateWireIns() self.dev.SetWireInValue(0x02,0) self.dev.UpdateWireIns() print "Done" #Searching for an external clock print "Setting clock to external...", if self.set_clock(0) == True: print "Done" else: print "Failed\nThere is no external clock connected!" #Resetting the PLL and the phaseshift module if self.reset_pll() == False: print "PLL could not be resetted!" sys.exit(1) if verbose: print "\n Initialising wires:" print " pattern_ena = 1" print " trigger data = 0" print " rate parameter = 256" print " all memory data = 0" print " count_mod = %d"%(self.memsize) print "\n" self.dev.SetWireInValue(0x00,0x00000001) self.dev.SetWireInValue(0x01,0x00000100) self.dev.SetWireInValue(0x02,0x00000000) self.dev.SetWireInValue(0x03,0x00000000) self.dev.SetWireInValue(0x04,0x00000000) self.dev.SetWireInValue(0x05,0x00000000) self.dev.SetWireInValue(0x06,self.memsize) self.dev.SetWireInValue(0x07,0x00000000) self.dev.UpdateWireIns() print "\n" self.reset_ran() #self.reset_phs() return