<s> from abc import ABCMeta , abstractmethod <EOL> from voodoo . override import Override <EOL> from experiments . ud_xilinx . exc import InvalidDeviceToProgramError <EOL> from weblab . experiment . devices . xilinx . programmers . digilent_adept import DigilentAdept <EOL> from weblab . experiment . devices . xilinx . programmers . jtag_blazer import JTagBlazer <EOL> from weblab . experiment . devices . xilinx . programmers . xcs3prog import Xcs3prog <EOL> from weblab . experiment . devices . xilinx . programmers . xilinx_impact . impact import XilinxImpact <EOL> class XilinxProgrammer ( object ) : <EOL> """<STR_LIT>""" <EOL> __metaclass__ = ABCMeta <EOL> def __init__ ( self , cfg_manager , xilinx_board_type ) : <EOL> super ( XilinxProgrammer , self ) . __init__ ( ) <EOL> self . _cfg_manager = cfg_manager <EOL> self . _xilinx_board_type = xilinx_board_type <EOL> @ staticmethod <EOL> def create ( programmer_name , cfg_manager , xilinx_board_type ) : <EOL> if programmer_name == '<STR_LIT>' : <EOL> return XilinxImpactProgrammer ( cfg_manager , xilinx_board_type ) <EOL> elif programmer_name == '<STR_LIT>' : <EOL> return JTagBlazerSvfProgrammer ( cfg_manager , xilinx_board_type ) <EOL> elif programmer_name == '<STR_LIT>' : <EOL> return DigilentAdeptSvfProgrammer ( cfg_manager , xilinx_board_type ) <EOL> elif programmer_name == '<STR_LIT>' : <EOL> return Xcs3progProgrammer ( cfg_manager , xilinx_board_type ) <EOL> else : <EOL> print "<STR_LIT>" + programmer_name <EOL> raise InvalidDeviceToProgramError ( programmer_name ) <EOL> @ abstractmethod <EOL> def program ( self , file_name ) : <EOL> pass <EOL> @ abstractmethod <EOL> def get_suffix ( self ) : <EOL> pass <EOL> class Xcs3progProgrammer ( XilinxProgrammer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cfg_manager , xilinx_board_type ) : <EOL> super ( Xcs3progProgrammer , self ) . __init__ ( cfg_manager , xilinx_board_type ) <EOL> self . _xc3sprog_device = Xcs3prog ( cfg_manager ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def program ( self , file_name ) : <EOL> self . _xc3sprog_device . program_device ( file_name , self . _xilinx_board_type ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def get_suffix ( self ) : <EOL> if self . _xilinx_board_type == '<STR_LIT>' : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> class XilinxImpactProgrammer ( XilinxProgrammer ) : <EOL> def __init__ ( self , cfg_manager , xilinx_board_type ) : <EOL> super ( XilinxImpactProgrammer , self ) . __init__ ( cfg_manager , xilinx_board_type ) <EOL> self . _xilinx_impact_device = XilinxImpact ( cfg_manager ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def program ( self , file_name ) : <EOL> self . _xilinx_impact_device . program_device ( file_name ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def get_suffix ( self ) : <EOL> if self . _xilinx_board_type == '<STR_LIT>' : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> class JTagBlazerSvfProgrammer ( XilinxProgrammer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cfg_manager , xilinx_board_type ) : <EOL> super ( JTagBlazerSvfProgrammer , self ) . __init__ ( cfg_manager , xilinx_board_type ) <EOL> self . _jtag_blazer = JTagBlazer ( cfg_manager ) <EOL> self . _device_ip = self . _cfg_manager . get_value ( '<STR_LIT>' ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def program ( self , file_name ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> svf_file_name = file_name . replace ( "<STR_LIT:.>" + self . _xilinx_impact_device . get_suffix ( ) , "<STR_LIT>" ) <EOL> self . _jtag_blazer . program_device ( svf_file_name , self . _device_ip ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def get_suffix ( self ) : <EOL> if self . _xilinx_board_type == '<STR_LIT>' : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> class DigilentAdeptSvfProgrammer ( XilinxProgrammer ) : <EOL> def __init__ ( self , cfg_manager , xilinx_board_type ) : <EOL> super ( DigilentAdeptSvfProgrammer , self ) . __init__ ( cfg_manager , xilinx_board_type ) <EOL> self . _digilent_adept = DigilentAdept ( cfg_manager ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def program ( self , file_name ) : <EOL> self . _digilent_adept . program_device ( file_name ) <EOL> @ Override ( XilinxProgrammer ) <EOL> def get_suffix ( self ) : <EOL> if self . _xilinx_board_type == '<STR_LIT>' : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" </s>
