Example #1
0
def main():
    from colorama import Fore, Back, Style, init

    init()

    print(Fore.MAGENTA + "=" * 80)
    print("{: ^80s}".format(Testbench.headLine))
    print("=" * 80)
    print(Fore.RESET + Back.RESET + Style.RESET_ALL)

    try:
        import argparse
        import textwrap

        # create a commandline argument parser
        argParser = argparse.ArgumentParser(
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=textwrap.dedent(
                """\
				This is the PoC Library Testbench Service Tool.
				"""
            ),
            add_help=False,
        )

        # add arguments
        group1 = argParser.add_argument_group("Verbosity")
        group1.add_argument(
            "-D", help="enable script wrapper debug mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-d", dest="debug", help="enable debug mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-v", dest="verbose", help="print out detailed messages", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-q", dest="quiet", help="run in quiet mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-r", dest="showReport", help="show report", action="store_const", const=True, default=False
        )
        group1.add_argument("-l", dest="showLog", help="show logs", action="store_const", const=True, default=False)
        group2 = argParser.add_argument_group("Commands")
        group21 = group2.add_mutually_exclusive_group(required=True)
        group21.add_argument(
            "-h",
            "--help",
            dest="help",
            help="show this help message and exit",
            action="store_const",
            const=True,
            default=False,
        )
        group21.add_argument("--list", metavar="<Entity>", dest="list", help="list available testbenches")
        group21.add_argument("--isim", metavar="<Entity>", dest="isim", help="use Xilinx ISE Simulator (isim)")
        group21.add_argument("--xsim", metavar="<Entity>", dest="xsim", help="use Xilinx Vivado Simulator (xsim)")
        group21.add_argument("--vsim", metavar="<Entity>", dest="vsim", help="use Mentor Graphics Simulator (vsim)")
        group21.add_argument("--ghdl", metavar="<Entity>", dest="ghdl", help="use GHDL Simulator (ghdl)")
        group3 = argParser.add_argument_group("Options")
        group3.add_argument(
            "--std", metavar="<version>", dest="std", help="set VHDL standard [87,93,02,08]; default=93"
        )
        # 		group3.add_argument('-i', '--interactive',					dest="interactive",	help='start simulation in interactive mode',	action='store_const', const=True, default=False)
        group3.add_argument(
            "-g",
            "--gui",
            dest="gui",
            help="start simulation in gui mode",
            action="store_const",
            const=True,
            default=False,
        )

        # parse command line options
        args = argParser.parse_args()

    except Exception as ex:
        Exit.printException(ex)

        # create class instance and start processing
    try:
        test = Testbench(args.debug, args.verbose, args.quiet)

        if args.help == True:
            argParser.print_help()
            print()
            return
        elif args.list is not None:
            test.listSimulations(args.list)
        elif args.isim is not None:
            iSimGUIMode = args.gui

            test.iSimSimulation(args.isim, args.showLog, args.showReport, iSimGUIMode)
        elif args.xsim is not None:
            xSimGUIMode = args.gui

            test.xSimSimulation(args.xsim, args.showLog, args.showReport, xSimGUIMode)
        elif args.vsim is not None:
            if (args.std is not None) and (args.std in ["87", "93", "02", "08"]):
                vhdlStandard = args.std
            else:
                vhdlStandard = "93"

            vSimGUIMode = args.gui

            test.vSimSimulation(args.vsim, args.showLog, args.showReport, vhdlStandard, vSimGUIMode)
        elif args.ghdl is not None:
            if (args.std is not None) and (args.std in ["87", "93", "02", "08"]):
                vhdlStandard = args.std
            else:
                vhdlStandard = "93"

            ghdlGUIMode = args.gui

            test.ghdlSimulation(args.ghdl, args.showLog, args.showReport, vhdlStandard, ghdlGUIMode)
        else:
            argParser.print_help()

    except SimulatorException as ex:
        from colorama import Fore, Back, Style
        from configparser import Error

        print(Fore.RED + "ERROR:" + Fore.RESET + " %s" % ex.message)
        if isinstance(ex.__cause__, FileNotFoundError):
            print(Fore.YELLOW + "  FileNotFound:" + Fore.RESET + " '%s'" % str(ex.__cause__))
        elif isinstance(ex.__cause__, Error):
            print(Fore.YELLOW + "  configparser.Error:" + Fore.RESET + " %s" % str(ex.__cause__))
        print(Fore.RESET + Back.RESET + Style.RESET_ALL)
        exit(1)

    except EnvironmentException as ex:
        Exit.printEnvironmentException(ex)
    except NotConfiguredException as ex:
        Exit.printNotConfiguredException(ex)
    except PlatformNotSupportedException as ex:
        Exit.printPlatformNotSupportedException(ex)
    except BaseException as ex:
        Exit.printBaseException(ex)
    except NotImplementedException as ex:
        Exit.printNotImplementedException(ex)
    except Exception as ex:
        Exit.printException(ex)
Example #2
0
def main():
	from colorama import Fore, Back, Style, init
	init()
	
	print(Fore.MAGENTA + "=" * 80)
	print("{: ^80s}".format("The PoC Library - NetList Service Tool"))
	print("=" * 80)
	print(Fore.RESET + Back.RESET + Style.RESET_ALL)
	
	try:
		import argparse
		import textwrap
		
		# create a command line argument parser
		argParser = argparse.ArgumentParser(
			formatter_class = argparse.RawDescriptionHelpFormatter,
			description = textwrap.dedent('''\
				This is the PoC Library NetList Service Tool.
				'''),
			add_help=False)

		# add arguments
		group1 = argParser.add_argument_group('Verbosity')
		group1.add_argument('-D', 																											help='enable script wrapper debug mode',	action='store_const', const=True, default=False)
		group1.add_argument('-d',																		dest="debug",				help='enable debug mode',									action='store_const', const=True, default=False)
		group1.add_argument('-v',																		dest="verbose",			help='print out detailed messages',				action='store_const', const=True, default=False)
		group1.add_argument('-q',																		dest="quiet",				help='run in quiet mode',									action='store_const', const=True, default=False)
		group1.add_argument('-r',																		dest="showReport",	help='show report',												action='store_const', const=True, default=False)
		group1.add_argument('-l',																		dest="showLog",			help='show logs',													action='store_const', const=True, default=False)
		group2 = argParser.add_argument_group('Commands')
		group21 = group2.add_mutually_exclusive_group(required=True)
		group21.add_argument('-h', '--help',												dest="help",				help='show this help message and exit',		action='store_const', const=True, default=False)
		group211 = group21.add_mutually_exclusive_group()
		group211.add_argument(		 '--coregen',	metavar="<Entity>",	dest="coreGen",			help='use Xilinx IP-Core Generator (CoreGen)')
		group211.add_argument(		 '--xst',			metavar="<Entity>",	dest="xst",					help='use Xilinx Compiler Tool (XST)')
		group3 = group211.add_argument_group('Specify target platform')
		group31 = group3.add_mutually_exclusive_group()
		group31.add_argument('--device',				metavar="<Device>",	dest="device",			help='target device (e.g. XC5VLX50T-1FF1136)')
		group31.add_argument('--board',					metavar="<Board>",	dest="board",				help='target board to infere the device (e.g. ML505)')

		# parse command line options
		args = argParser.parse_args()
		
	except Exception as ex:
		Exit.printException(ex)
		
	try:
		netList = NetList(args.debug, args.verbose, args.quiet)
		#netList.dryRun = True
	
		if (args.help == True):
			argParser.print_help()
			return
		elif (args.coreGen is not None):
			netList.coreGenCompilation(args.coreGen, args.showLog, args.showReport, deviceString=args.device, boardString=args.board)
		elif (args.xst is not None):
			netList.xstCompilation(args.xst, args.showLog, args.showReport, deviceString=args.device, boardString=args.board)
		else:
			argParser.print_help()
		
	except CompilerException as ex:
		from colorama import Fore, Back, Style
		from configparser import Error
		
		print(Fore.RED + "ERROR:" + Fore.RESET + " %s" % ex.message)
		if isinstance(ex.__cause__, FileNotFoundError):
			print(Fore.YELLOW + "  FileNotFound:" + Fore.RESET + " '%s'" % str(ex.__cause__))
		elif isinstance(ex.__cause__, Error):
			print(Fore.YELLOW + "  configparser.Error:" + Fore.RESET + " %s" % str(ex.__cause__))
		print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		exit(1)
		
	except EnvironmentException as ex:					Exit.printEnvironmentException(ex)
	except NotConfiguredException as ex:				Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex:	Exit.printPlatformNotSupportedException(ex)
	except BaseException as ex:									Exit.printBaseException(ex)
	except NotImplementedException as ex:				Exit.printNotImplementedException(ex)
	except Exception as ex:											Exit.printException(ex)
Example #3
0
def main():
	from sys import exit
	import argparse
	import textwrap
	import colorama
	
	colorama.init()
	
	try:
		# create a commandline argument parser
		argParser = argparse.ArgumentParser(
			formatter_class = argparse.RawDescriptionHelpFormatter,
			description = textwrap.dedent('''\
				This is the PoC-Library Repository Service Tool.
				'''),
			add_help=False)

		# add arguments
		group1 = argParser.add_argument_group('Verbosity')
		group1.add_argument('-D', 																														help='enable script wrapper debug mode',		action='store_const', const=True, default=False)
		group1.add_argument('-d',																	dest="debug",								help='enable debug mode',										action='store_const', const=True, default=False)
		group1.add_argument('-v',																	dest="verbose",							help='print out detailed messages',					action='store_const', const=True, default=False)
		group1.add_argument('-q',																	dest="quiet",								help='run in quiet mode',										action='store_const', const=True, default=False)
		group2 = argParser.add_argument_group('Commands')
		group21 = group2.add_mutually_exclusive_group(required=True)
		group21.add_argument('-h', '--help',											dest="help",								help='show this help message and exit',			action='store_const', const=True, default=False)
		group21.add_argument('--configure',												dest="configurePoC",				help='configure PoC Library',								action='store_const', const=True, default=False)
		group21.add_argument('--new-solution',	metavar="<Name>",	dest="newSolution",					help='create a new solution')
		group21.add_argument('--add-solution',	metavar="<Name>",	dest="addSolution",					help='add an existing solution')
		group21.add_argument('--ise-settingsfile',								dest="iseSettingsFile",			help='return Xilinx ISE settings file',			action='store_const', const=True, default=False)
		group21.add_argument('--vivado-settingsfile',							dest="vivadoSettingsFile",	help='return Xilinx Vivado settings file',	action='store_const', const=True, default=False)

		# parse command line options
		args = argParser.parse_args()

	except Exception as ex:
		Exit.printException(ex)

	# create class instance and start processing
	try:
		from colorama import Fore, Back, Style
		
		config = Configuration(args.debug, args.verbose, args.quiet)
		
		if (args.help == True):
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			argParser.print_help()
			return
		elif args.configurePoC:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			#config.autoConfiguration()
			config.manualConfiguration()
			exit(0)
			
		elif args.newSolution:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
			
			config.newSolution(args.newSolution)
			exit(0)
			
		elif args.addSolution:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
			
			config.addSolution(args.addSolution)
			exit(0)
			
		elif args.iseSettingsFile:
			print(config.getISESettingsFile())
			exit(0)
		elif args.vivadoSettingsFile:
			print(config.getVivadoSettingsFile())
			exit(0)
		else:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			argParser.print_help()
			exit(0)
	
#	except ConfiguratorException as ex:
#		from colorama import Fore, Back, Style
#		print(Fore.RED + "ERROR:" + Fore.RESET + " %s" % ex.message)
#		if isinstance(ex.__cause__, FileNotFoundError):
#			print(Fore.YELLOW + "  FileNotFound:" + Fore.RESET + " '%s'" % str(ex.__cause__))
#		print(Fore.RESET + Back.RESET + Style.RESET_ALL)
#		exit(1)
		
	except NotConfiguredException as ex:				Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex:	Exit.printPlatformNotSupportedException(ex)
	except BaseException as ex:									Exit.printBaseException(ex)
	except NotImplementedException as ex:				Exit.printNotImplementedException(ex)
	except Exception as ex:											Exit.printException(ex)