args = parser.parse_args() prj = Project('openflow') prj.set_outdir('../../build/icestorm-{}'.format(args.lang)) prj.set_part('hx4k-tq144') if args.lang == 'verilog': prj.add_path('../../hdl/headers1') prj.add_path('../../hdl/headers2') prj.add_files('../../hdl/blinking.v') prj.add_files('../../hdl/top.v') else: # args.lang == 'vhdl' prj.add_files('../../hdl/blinking.vhdl', library='examples') prj.add_files('../../hdl/examples_pkg.vhdl', library='examples') prj.add_files('../../hdl/top.vhdl') prj.add_files('*.pcf') prj.set_top('Top') if args.action in ['generate', 'all']: try: prj.generate() except RuntimeError: print('ERROR:generate:Docker not found') if args.action in ['transfer', 'all']: try: prj.transfer() except RuntimeError: print('ERROR:transfer:Docker not found')
parser.add_argument( '--action', choices=['generate', 'transfer', 'all'], default='generate', ) args = parser.parse_args() prj = Project('quartus') prj.set_part('5CSEBA6U23I7') prj.set_outdir('../../build/quartus') prj.add_files('../../hdl/blinking.vhdl', library='examples') prj.add_files('../../hdl/examples_pkg.vhdl', library='examples') prj.add_files('../../hdl/top.vhdl') prj.set_top('Top') prj.add_files('de10nano.sdc') prj.add_files('de10nano.tcl') if args.action in ['generate', 'all']: try: prj.generate() except RuntimeError: print('ERROR:generate:Quartus not found') if args.action in ['transfer', 'all']: try: prj.transfer('fpga', 2) except RuntimeError: print('ERROR:transfer:Quartus not found')
default='generate', ) args = parser.parse_args() prj = Project('ise') prj.set_part('XC6SLX9-2-CSG324') prj.set_outdir('../../build/ise') prj.add_files('../../hdl/blinking.vhdl', library='examples') prj.add_files('../../hdl/examples_pkg.vhdl', library='examples') prj.add_files('../../hdl/top.vhdl') prj.set_top('Top') prj.add_files('s6micro.xcf') prj.add_files('s6micro.ucf') if args.action in ['generate', 'all']: try: prj.generate() except RuntimeError: print('ERROR:generate:ISE not found') if args.action in ['transfer', 'all']: try: prj.transfer('fpga') # prj.transfer('detect') # prj.transfer('unlock') # prj.transfer('spi', 1, 'N25Q128', 4) except RuntimeError: print('ERROR:transfer:ISE not found')
def main(): """Solves the main functionality of this helper.""" # Parsing the command-line. parser = argparse.ArgumentParser( description=__doc__, epilog=EPILOGUE, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-v', '--version', action='version', version='v{}'.format(version)) parser.add_argument('bit', metavar='BITFILE', nargs='?', help='a bitstream file') parser.add_argument('-t', '--tool', metavar='TOOL', default='vivado', choices=TOOLS, help='backend tool to be used [vivado]') parser.add_argument('-o', '--outdir', metavar='PATH', default='temp', help='where to generate files [temp]') parser.add_argument('-d', '--device', metavar='DEVTYPE', choices=DEVS, default=DEVS[0], help='the target device type [{}]'.format(DEVS[0])) parser.add_argument('-p', '--position', metavar='POSITION', choices=POSITIONS, type=int, default=1, help='the device position into the JTAG chain [1]') parser.add_argument('-m', '--memname', metavar='MEMNAME', default='', help='memory name if spi or bpi selected') parser.add_argument('-w', '--width', metavar='MEMWIDTH', choices=MEMWIDTHS, type=int, default=1, help='memory width if spi or bpi selected [1]') parser.add_argument('--run', metavar='ACTION', choices=ACTIONS, default=ACTIONS[0], help='action to perform [{}]'.format(ACTIONS[0])) args = parser.parse_args() # Solving with PyFPGA prj = Project(args.tool, relative_to_script=False) prj.set_outdir(args.outdir) if args.run == 'program': devtype = args.device prj.set_bitstream(args.bit) elif args.run == 'detect': devtype = 'detect' else: # args.run == 'unlock' devtype = 'unlock' try: prj.transfer(devtype, args.position, args.memname, args.width) except RuntimeError: logging.error('{} not found'.format(args.tool)) except Exception as e: sys.exit('{} ({})'.format(type(e).__name__, e))