Ejemplo n.º 1
0
 def init(self, **kwargs):
     self._init.setdefault('board_id', None)
     self._init.setdefault('avoid_download', False)
     if self._init['board_id'] and int(self._init['board_id']) >= 0:
         self._sidev = SiUSBDevice.from_board_id(self._init['board_id'])
     else:
         # search for any available device
         devices = GetUSBBoards()
         if not devices:
             raise IOError('Can\'t find USB board. Connect or reset USB board!')
         else:
             logging.info('Found USB board(s): {}'.format(', '.join(('%s with ID %s (FW %s)' % (device.board_name, filter(type(device.board_id).isdigit, device.board_id), filter(type(device.fw_version).isdigit, device.fw_version))) for device in devices)))
             if len(devices) > 1:
                 raise ValueError('Please specify ID of USB board')
             self._sidev = devices[0]
     if 'bit_file' in self._init.keys():
         if 'avoid_download' in self._init.keys() and self._init['avoid_download'] is True and self._sidev.XilinxAlreadyLoaded():
             logging.info("FPGA already programmed, skipping download")
         else:
             if os.path.exists(self._init['bit_file']):
                 bit_file = self._init['bit_file']
             elif os.path.exists(os.path.join(os.path.dirname(self.parent.conf_path), self._init['bit_file'])):
                 bit_file = os.path.join(os.path.dirname(self.parent.conf_path), self._init['bit_file'])
             else:
                 raise ValueError('No such bit file: %s' % self._init['bit_file'])
             logging.info("Programming FPGA: %s..." % (self._init['bit_file']))
             status = self._sidev.DownloadXilinx(bit_file)
             logging.log(logging.INFO if status else logging.ERROR, 'Success!' if status else 'Failed!')
     else:
         if not self._sidev.XilinxAlreadyLoaded():
             raise ValueError('FPGA not initialized, bit_file not specified')
         else:
             logging.info("Programming FPGA: bit_file not specified")
Ejemplo n.º 2
0
 def init(self, **kwargs):
     self._init.setdefault('board_id', None)
     self._init.setdefault('avoid_download', False)
     if self._init['board_id'] and int(self._init['board_id']) >= 0:
         self._sidev = SiUSBDevice.from_board_id(self._init['board_id'])
     else:
         # search for any available device
         devices = GetUSBBoards()
         if not devices:
             raise IOError('Can\'t find USB board. Connect or reset USB board!')
         else:
             logging.info('Found USB board(s): {}'.format(', '.join(('%s with ID %s (FW %s)' % (device.board_name, filter(type(device.board_id).isdigit, device.board_id), filter(type(device.fw_version).isdigit, device.fw_version))) for device in devices)))
             if len(devices) > 1:
                 raise ValueError('Please specify ID of USB board')
             self._sidev = devices[0]
     if 'bit_file' in self._init.keys():
         if 'avoid_download' in self._init.keys() and self._init['avoid_download'] is True and self._sidev.XilinxAlreadyLoaded():
             logging.info("FPGA already programmed, skipping download")
         else:
             if os.path.exists(self._init['bit_file']):
                 bit_file = self._init['bit_file']
             elif os.path.exists(os.path.join(os.path.dirname(self.parent.conf_path), self._init['bit_file'])):
                 bit_file = os.path.join(os.path.dirname(self.parent.conf_path), self._init['bit_file'])
             else:
                 raise ValueError('No such bit file: %s' % self._init['bit_file'])
             logging.info("Programming FPGA: %s..." % (self._init['bit_file']))
             status = self._sidev.DownloadXilinx(bit_file)
             logging.log(logging.INFO if status else logging.ERROR, 'Success!' if status else 'Failed!')
     else:
         if not self._sidev.XilinxAlreadyLoaded():
             raise ValueError('FPGA not initialized, bit_file not specified')
         else:
             logging.info("Programming FPGA: bit_file not specified")
Ejemplo n.º 3
0
    def init(self):
        super(SiUsb, self).init()
        self._init.setdefault('board_id', None)
        self._init.setdefault('avoid_download', False)
        if self._init['board_id'] and int(self._init['board_id']) >= 0:
            self._sidev = SiUSBDevice.from_board_id(self._init['board_id'])
        else:
            # search for any available device
            devices = GetUSBBoards()
            if not devices:
                raise IOError(
                    'Can\'t find USB board. Connect or reset USB board!')
            else:
                logger.info('Found USB board(s): {}'.format(', '.join(
                    ('%s with ID %s (FW %s)' %
                     (device.board_name,
                      "".join(filter(str.isdigit, device.board_id)),
                      "".join(filter(str.isdigit, device.fw_version))))
                    for device in devices)))
                if len(devices) > 1:
                    raise ValueError('Please specify ID of USB board')
                self._sidev = devices[0]
        if 'bit_file' in self._init.keys():
            if 'avoid_download' in self._init.keys() and self._init[
                    'avoid_download'] is True and self._sidev.XilinxAlreadyLoaded(
                    ):
                logger.info("FPGA already programmed, skipping download")
            else:
                # invert polarity of the interface clock (IFCONFIG.4) -> IFCLK & UCLK are in-phase
                ifconfig = self._sidev._Read8051(0xE601, 1)[0]
                ifconfig = ifconfig & ~0x10
                self._sidev._Write8051(0xE601, [ifconfig])

                if os.path.exists(self._init['bit_file']):
                    bit_file = self._init['bit_file']
                elif os.path.exists(
                        os.path.join(os.path.dirname(self.parent.conf_path),
                                     self._init['bit_file'])):
                    bit_file = os.path.join(
                        os.path.dirname(self.parent.conf_path),
                        self._init['bit_file'])
                else:
                    raise ValueError('No such bit file: %s' %
                                     self._init['bit_file'])
                logger.info("Programming FPGA: %s..." %
                            (self._init['bit_file']))
                status = self._sidev.DownloadXilinx(bit_file)
                logger.log(logging.INFO if status else logging.ERROR,
                           'Success!' if status else 'Failed!')
        else:
            if not self._sidev.XilinxAlreadyLoaded():
                raise ValueError(
                    'FPGA not initialized, bit_file not specified')
            else:
                logger.info("Programming FPGA: bit_file not specified")
Ejemplo n.º 4
0
 def init(self, **kwargs):
     self._init.setdefault('board_id', None)
     self._init.setdefault('avoid_download', False)
     if self._init['board_id'] and int(self._init['board_id']) >= 0:
         self._sidev = SiUSBDevice.from_board_id(self._init['board_id'])
     else:
         # search for any available device
         devices = GetUSBBoards()
         if not devices:
             raise IOError('Can\'t find USB board. Connect or reset USB board!')
         else:
             logging.info('Found USB board(s): {}'.format(', '.join(('%s with ID %s (FW %s)' % (device.board_name, filter(type(device.board_id).isdigit, device.board_id), filter(type(device.fw_version).isdigit, device.fw_version))) for device in devices)))
             if len(devices) > 1:
                 raise ValueError('Please specify ID of USB board')
             self._sidev = devices[0]
Ejemplo n.º 5
0
 def init(self):
     super(SiUsb3, self).init()
     self._init.setdefault('board_id', None)
     self._init.setdefault('avoid_download', False)
     if self._init['board_id'] and int(self._init['board_id']) >= 0:
         self._sidev = SiUSBDevice.from_board_id(self._init['board_id'])
     else:
         # search for any available device
         devices = GetUSBBoards()
         if not devices:
             raise IOError('Can\'t find USB board. Connect or reset USB board!')
         else:
             logger.info('Found USB board(s): {}'.format(', '.join(('%s with ID %s (FW %s)' % (device.board_name, list(filter(type(device.board_id).isdigit, device.board_id)), list(filter(type(device.fw_version).isdigit, device.fw_version)))) for device in devices)))
             if len(devices) > 1:
                 raise ValueError('Please specify ID of USB board')
             self._sidev = devices[0]