def cli(ctx, board, scons, project_dir, sayyes): """Manage apio projects.""" if scons: Project().create_sconstruct(project_dir, sayyes) elif board: Project().create_ini(board, project_dir, sayyes) else: click.secho(ctx.get_help())
def __init__(self): self.board="icezum" self.scons_engine=SCons(".") #Ahora mismo da problemas self.project=Project()
class FPGA_engine(object): def __init__(self): self.board="icezum" self.scons_engine=SCons(".") #Ahora mismo da problemas self.project=Project() def config_fpga(self): print("\n\n"+pythonsays_memo+"Calling APIO FPGA Board Setup (PROJECT)"+"\n\n") #project=Project() self.project.create_ini(self.board, path, False) #apio.managers.scons.Project.create_ini(fpgaboard_name, path, False) #Another lower level option return True def verify_hdl(self): #subprocess.call('echo "\n\nCalling APIO Verify (SCONS)"' ,shell=True) print("\n\n"+pythonsays_memo+"Calling APIO Verify (SCONS)"+"\n\n") #scons_engine=SCons() self.scons_engine.verify() return True def build_hdl(self): print("\n\n"+pythonsays_memo+"BUILDING CIRCUIT"+"\n\n") #Apio building calling (SCONS) #scons_engine=SCons() ''' scons_engine.__init__()#Not needed scons_engine.build({ 'board': board, 'fpga': fpga, 'size': size, 'type': type, 'pack': pack }) ''' self.scons_engine.build({ #Details extracted from boards.json and fpgas.json Device argument must be 0 'board': "icezum", 'fpga': "iCE40-HX1K-TQ144", 'size': "1k", 'type': "hx", 'pack': "tq144" }) return True def upload_hdl(self): print("\n\n"+pythonsays_memo+"UPLOADING CIRCUIT"+"\n\n") #scons_engine=SCons() self.scons_engine.upload({ #Details extracted from boards.json and fpgas.json Device argument must be 0 'board': "icezum", 'fpga': "iCE40-HX1K-TQ144", 'size': "1k", 'type': "hx", 'pack': "tq144" }, 0) return True def verify_build_upload(self): #This functions calls apio verify and apio upload, synthesizing the circuit in the process (build) print("\n\n"+pythonsays_memo+"VERIFY_BUILD_UPLOAD"+"\n\n") if self.verify_hdl()==True: if self.upload_hdl()==True: return True
def process_arguments(args, resources): # noqa # -- Check arguments var_board = args.get('board') var_fpga = args.get('fpga') var_size = args.get('size') var_type = args.get('type') var_pack = args.get('pack') var_verbose = args.get('verbose') if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') if fpga in resources.fpgas: fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA pass else: # Unknown board raise Exception('unknown board: {0}'.format(var_board)) else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in resources.fpgas: fpga_size = resources.fpgas.get(var_fpga).get('size') fpga_type = resources.fpgas.get(var_fpga).get('type') fpga_pack = resources.fpgas.get(var_fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') else: # Unknown board raise Exception( 'unknown board: {0}'.format(var_board)) else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho('You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') raise Exception else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] raise Exception( 'insufficient arguments: missing {}'.format( ', '.join(missing))) # -- Build Scons variables list variables = format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack, 'verbose_all': var_verbose.get('all'), 'verbose_yosys': var_verbose.get('yosys'), 'verbose_arachne': var_verbose.get('arachne') }) return variables, var_board
def __init__(self): self.board = "icezum" self.scons_engine = SCons(".") self.project = Project()
def process_arguments(self, args): # -- Check arguments var_board = args['board'] var_fpga = args['fpga'] var_size = args['size'] var_type = args['type'] var_pack = args['pack'] # TODO: reduce code size if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in self.resources.boards: fpga = self.resources.boards[var_board]['fpga'] if fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in self.resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga pass else: # Unknown board click.secho('Error: unknown board: {0}'.format(var_board), fg='red') return 1 else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[var_fpga]['size'] fpga_type = self.resources.fpgas[var_fpga]['type'] fpga_pack = self.resources.fpgas[var_fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga click.secho('Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board click.secho('Info: use apio.ini board: {}'.format( var_board)) fpga = self.resources.boards[var_board]['fpga'] fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') return 1 else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] pass click.secho( 'Error: insufficient arguments: missing {}'.format( ', '.join(missing)), fg='red') return 1 # -- Build Scons variables list variables = self.format_vars({ "fpga_size": fpga_size, "fpga_type": fpga_type, "fpga_pack": fpga_pack }) return variables, var_board
def process_arguments(self, args): # -- Check arguments var_board = args['board'] var_fpga = args['fpga'] var_size = args['size'] var_type = args['type'] var_pack = args['pack'] # TODO: reduce code size if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in self.resources.boards: fpga = self.resources.boards[var_board]['fpga'] if fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in self.resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format( var_fpga), fg='red') return 1 if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga pass else: # Unknown board click.secho( 'Error: unknown board: {0}'.format(var_board), fg='red') return 1 else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[var_fpga]['size'] fpga_type = self.resources.fpgas[var_fpga]['type'] fpga_pack = self.resources.fpgas[var_fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board click.secho( 'Info: use apio.ini board: {}'.format( var_board)) fpga = self.resources.boards[var_board]['fpga'] fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') return 1 else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] pass click.secho( 'Error: insufficient arguments: missing {}'.format( ', '.join(missing)), fg='red') return 1 # -- Build Scons variables list variables = self.format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack }) return variables, var_board
def process_arguments(args, resources): # noqa # -- Check arguments var_board = args.get('board') var_fpga = args.get('fpga') var_size = args.get('size') var_type = args.get('type') var_pack = args.get('pack') var_verbose = args.get('verbose') if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') if fpga in resources.fpgas: fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA pass else: # Unknown board raise Exception('unknown board: {0}'.format(var_board)) else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in resources.fpgas: fpga_size = resources.fpgas.get(var_fpga).get('size') fpga_type = resources.fpgas.get(var_fpga).get('type') fpga_pack = resources.fpgas.get(var_fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') else: # Unknown board raise Exception('unknown board: {0}'.format( var_board)) else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') raise Exception else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] raise Exception( 'insufficient arguments: missing {}'.format( ', '.join(missing))) # -- Build Scons variables list variables = format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack, 'verbose_all': var_verbose.get('all'), 'verbose_yosys': var_verbose.get('yosys'), 'verbose_arachne': var_verbose.get('arachne') }) return variables, var_board