Exemple #1
0
	def HandleListNetlist(self, args):
		self.PrintHeadline()
		self.__PrepareForSynthesis()

		if (args.NetlistKind is None):
			nlFilter = NetlistKind.All
		else:
			nlFilter = NetlistKind.Unknown
			for kind in args.TestbenchKind.lower().split(","):
				if   (kind == "lattice"):  nlFilter |= NetlistKind.LatticeNetlist
				elif (kind == "quartus"):  nlFilter |= NetlistKind.QuartusNetlist
				elif (kind == "xst"):      nlFilter |= NetlistKind.XstNetlist
				elif (kind == "coregen"):  nlFilter |= NetlistKind.CoreGeneratorNetlist
				elif (kind == "vivado"):   nlFilter |= NetlistKind.VivadoNetlist
				else:                      raise CommonException("Argument --kind has an unknown value '{0}'.".format(kind))

		fqnList = self._ExtractFQNs(args.FQN)
		for fqn in fqnList:
			entity = fqn.Entity
			if (isinstance(entity, WildCard)):
				for testbench in entity.GetNetlists(nlFilter):
					print(str(testbench))
			else:
				testbench = entity.GetNetlists(nlFilter)
				print(str(testbench))

		Exit.exit()
Exemple #2
0
	def HandleHelp(self, args):
		self.PrintHeadline()
		if (args.Command is None):
			self.MainParser.print_help()
			Exit.exit()
		elif (args.Command == "help"):
			print("This is a recursion ...")
		else:
			self.SubParsers[args.Command].print_help()
		Exit.exit()
Exemple #3
0
	def HandleQueryConfiguration(self, args):
		self.__PrepareForConfiguration()
		query = Query(self)
		try:
			result = query.QueryConfiguration(args.Query)
			print(result, end="")
			Exit.exit()
		except ConfigurationException as ex:
			print(str(ex), end="")
			Exit.exit(1)
Exemple #4
0
	def HandleISESimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()
		self._CheckISEEnvironment()
		
		fqnList =      self._ExtractFQNs(args.FQN)
		board =        self._ExtractBoard(args.BoardName, args.DeviceName)

		simulator = ISESimulator(self, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=VHDLVersion.VHDL93)		#, vhdlGenerics=None)

		Exit.exit(0 if allPassed else 1)
Exemple #5
0
	def HandleQuestaSimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		fqnList =      self._ExtractFQNs(args.FQN)
		board =        self._ExtractBoard(args.BoardName, args.DeviceName)
		vhdlVersion =  self._ExtractVHDLVersion(args.VHDLVersion)

		simulator = QuestaSimulator(self, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=vhdlVersion)  # , vhdlGenerics=None)

		Exit.exit(0 if allPassed else 1)
Exemple #6
0
	def HandleVivadoCompilation(self, args):
		self.PrintHeadline()
		self.__PrepareForSynthesis()
		self._CheckVivadoEnvironment()

		fqnList =  self._ExtractFQNs(args.FQN, defaultType=EntityTypes.NetList)
		board =    self._ExtractBoard(args.BoardName, args.DeviceName, force=True)

		compiler = VivadoCompiler(self, self.DryRun, args.NoCleanUp)
		compiler.RunAll(fqnList, board)

		Exit.exit()
Exemple #7
0
	def HandleActiveHDLSimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		fqnList =      self._ExtractFQNs(args.FQN)
		board =        self._ExtractBoard(args.BoardName, args.DeviceName)
		vhdlVersion =  self._ExtractVHDLVersion(args.VHDLVersion)

		# create a GHDLSimulator instance and prepare it
		simulator = ActiveHDLSimulator(self, self.DryRun, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=vhdlVersion)  # , vhdlGenerics=None)

		Exit.exit(0 if allPassed else 1)
Exemple #8
0
	def HandleVivadoSimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		self._CheckVivadoEnvironment()
		
		fqnList =      self._ExtractFQNs(args.FQN)
		board =        self._ExtractBoard(args.BoardName, args.DeviceName)
		# FIXME: VHDL-2008 is broken in Vivado 2016.1 -> use VHDL-93 by default
		vhdlVersion = self._ExtractVHDLVersion(args.VHDLVersion, defaultVersion=VHDLVersion.VHDL93)

		simulator = VivadoSimulator(self, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=vhdlVersion)  # , vhdlGenerics=None)

		Exit.exit(0 if allPassed else 1)
Exemple #9
0
	def HandleCocotbSimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		# check if QuestaSim is configured
		if (len(self.PoCConfig.options("INSTALL.Mentor.QuestaSim")) == 0):
			raise NotConfiguredException("Mentor QuestaSim is not configured on this system.")

		fqnList =  self._ExtractFQNs(args.FQN)
		board =    self._ExtractBoard(args.BoardName, args.DeviceName)

		# create a CocotbSimulator instance and prepare it
		simulator = CocotbSimulator(self, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=VHDLVersion.VHDL08)

		Exit.exit(0 if allPassed else 1)
Exemple #10
0
	def HandleDefault(self, _):
		self.PrintHeadline()

		# print("Common arguments:")
		# for funcname,func in CommonArgumentAttribute.GetMethods(self):
		# 	for comAttribute in CommonArgumentAttribute.GetAttributes(func):
		# 		print("  {0}  {1}".format(comAttribute.Args, comAttribute.KWArgs['help']))
		#
		# 		self.__mainParser.add_argument(*(comAttribute.Args), **(comAttribute.KWArgs))
		#
		# for funcname,func in CommonSwitchArgumentAttribute.GetMethods(self):
		# 	for comAttribute in CommonSwitchArgumentAttribute.GetAttributes(func):
		# 		print("  {0}  {1}".format(comAttribute.Args, comAttribute.KWArgs['help']))

		self.MainParser.print_help()
		Exit.exit()
Exemple #11
0
	def HandleGHDLSimulation(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		config = GHDLConfiguration(self)
		if (not config.IsSupportedPlatform()):    raise PlatformNotSupportedException()
		if (not config.IsConfigured()):            raise NotConfiguredException("GHDL is not configured on this system.")

		fqnList =      self._ExtractFQNs(args.FQN)
		board =        self._ExtractBoard(args.BoardName, args.DeviceName)
		vhdlVersion =  self._ExtractVHDLVersion(args.VHDLVersion)

		simulator = GHDLSimulator(self, args.GUIMode)
		allPassed = simulator.RunAll(fqnList, board=board, vhdlVersion=vhdlVersion, guiMode=args.GUIMode)		#, vhdlGenerics=None)

		Exit.exit(0 if allPassed else 1)
Exemple #12
0
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module Base.Exceptions")


class ExceptionBase(Exception):
	def __init__(self, message=""):
		super().__init__()
		self.message = message

	def __str__(self):
		return self.message

class EnvironmentException(ExceptionBase):
	pass

class PlatformNotSupportedException(ExceptionBase):
	pass
Exemple #13
0
        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)


# entry point
if __name__ == "__main__":
    Exit.versionCheck((3, 4, 0))
    main()
else:
    Exit.printThisIsNoLibraryFile(Testbench.headLine)
Exemple #14
0
	def HandleListTestbenches(self, args):
		self.PrintHeadline()
		self.__PrepareForSimulation()

		defaultLibrary = "PoC"

		if (args.SolutionID is not None):
			solutionName = args.SolutionID
			print("Solution name: {0}".format(solutionName))
			if self.PoCConfig.has_option("SOLUTION.Solutions", solutionName):
				sectionName = "SOLUTION.{0}".format(solutionName)
				print("Found registered solution:")
				print("  Name: {0}".format(self.PoCConfig[sectionName]['Name']))
				print("  Path: {0}".format(self.PoCConfig[sectionName]['Path']))

				solutionRootPath = self.Directories.Root / self.PoCConfig[sectionName]['Path']
				solutionConfigFile = solutionRootPath / ".PoC" / "solution.config.ini"
				solutionDefaultsFile = solutionRootPath / ".PoC" / "solution.defaults.ini"
				print("  sln files: {0!s}  {1!s}".format(solutionConfigFile, solutionDefaultsFile))

				self._LogVerbose("Reading solution file...")
				self._LogDebug("  {0!s}".format(solutionConfigFile))
				self._LogDebug("  {0!s}".format(solutionDefaultsFile))
				if not solutionConfigFile.exists():
					raise NotConfiguredException("Solution's {0} configuration file '{1!s}' does not exist.".format(solutionName, solutionConfigFile)) \
						from FileNotFoundError(str(solutionConfigFile))
				if not solutionDefaultsFile.exists():
					raise NotConfiguredException("Solution's {0} defaults file '{1!s}' does not exist.".format(solutionName, solutionDefaultsFile)) \
						from FileNotFoundError(str(solutionDefaultsFile))
				self.__pocConfig.read(str(solutionConfigFile))
				self.__pocConfig.read(str(solutionDefaultsFile))

				section =          self.PoCConfig['PROJECT.Projects']
				defaultLibrary =  section['DefaultLibrary']
				print("Solution:")
				print("  Name:            {0}".format(section['Name']))
				print("  Default library: {0}".format(defaultLibrary))
				print("  Projects:")
				for item in section:
					if (section[item] in ["PoCProject", "ISEProject", "VivadoProject", "QuartusProject"]):
						sectionName2 = "PROJECT.{0}".format(item)
						print("    {0}".format(self.PoCConfig[sectionName2]['Name']))

				print("  Namespace roots:")
				for item in section:
					if (section[item] == "Library"):
						libraryPrefix = item
						print("    {0: <16}  {1}".format(self.PoCConfig[libraryPrefix]['Name'], libraryPrefix))

						self.Root.AddLibrary(libraryPrefix, libraryPrefix)


		if (args.TestbenchKind is None):
			tbFilter =  TestbenchKind.All
		else:
			tbFilter =  TestbenchKind.Unknown
			for kind in args.TestbenchKind.lower().split(","):
				if   (kind == "vhdl"):    tbFilter |= TestbenchKind.VHDLTestbench
				elif (kind == "cocotb"):  tbFilter |= TestbenchKind.CocoTestbench
				else:                      raise CommonException("Argument --kind has an unknown value '{0}'.".format(kind))

		fqnList = self._ExtractFQNs(args.FQN, defaultLibrary)
		for fqn in fqnList:
			self._LogNormal("")
			entity = fqn.Entity
			if (isinstance(entity, WildCard)):
				for testbench in entity.GetTestbenches(tbFilter):
					print(str(testbench))
			else:
				testbench = entity.GetTestbenches(tbFilter)
				print(str(testbench))

		Exit.exit()
Exemple #15
0
	def HandleQueryConfiguration(self, args):
		self.__PrepareForConfiguration()
		query = Query(self)
		result = query.QueryConfiguration(args.Query)
		print(result, end="")
		Exit.exit()
Exemple #16
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)
Exemple #17
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)
Exemple #18
0
def main():  # mccabe:disable=MC0001
    """This is the entry point for pyIPCMI written as a function.

	1. It extracts common flags from the script's arguments list, before :py:class:`~argparse.ArgumentParser` is fully loaded.
	2. It initializes colorama for colored outputs
	3. It creates an instance of pyIPCMI and hands over to class based execution. All is wrapped in a big ``try..except`` block to catch every unhandled exception.
	4. Shutdown the script and return its exit code.
	"""

    dryRun = "--dryrun" in sys_argv
    debug = "-d" in sys_argv
    verbose = "-v" in sys_argv
    quiet = "-q" in sys_argv

    # configure Exit class
    Exit.quiet = quiet

    try:
        Init.init()
        # handover to a class instance
        pyIPCMI = IPCoreManagementInfrastructure(debug, verbose, quiet, dryRun)
        pyIPCMI.Run()
        Exit.exit()

    except (CommonException, ConfigurationException, SimulatorException,
            CompilerException) as ex:
        print("{RED}ERROR:{NOCOLOR} {message}".format(message=ex.message,
                                                      **Init.Foreground))
        cause = ex.__cause__
        if isinstance(cause, FileNotFoundError):
            print("{YELLOW}  FileNotFound:{NOCOLOR} '{cause}'".format(
                cause=str(cause), **Init.Foreground))
        elif isinstance(cause, NotADirectoryError):
            print("{YELLOW}  NotADirectory:{NOCOLOR} '{cause}'".format(
                cause=str(cause), **Init.Foreground))
        elif isinstance(cause, DuplicateOptionError):
            print("{YELLOW}  DuplicateOptionError:{NOCOLOR} '{cause}'".format(
                cause=str(cause), **Init.Foreground))
        elif isinstance(cause, ConfigParser_Error):
            print("{YELLOW}  configparser.Error:{NOCOLOR} '{cause}'".format(
                cause=str(cause), **Init.Foreground))
        elif isinstance(cause, ParserException):
            print("{YELLOW}  ParserException:{NOCOLOR} {cause}".format(
                cause=str(cause), **Init.Foreground))
            cause = cause.__cause__
            if (cause is not None):
                print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(
                    name=cause.__class__.__name__,
                    cause=str(cause),
                    **Init.Foreground))
        elif isinstance(cause, ToolChainException):
            print("{YELLOW}  {name}:{NOCOLOR} {cause}".format(
                name=cause.__class__.__name__,
                cause=str(cause),
                **Init.Foreground))
            cause = cause.__cause__
            if (cause is not None):
                if isinstance(cause, OSError):
                    print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(
                        name=cause.__class__.__name__,
                        cause=str(cause),
                        **Init.Foreground))
            else:
                print("  Possible causes:")
                print("   - The compile order is broken.")
                print(
                    "   - A source file was not compiled and an old file got used."
                )

        if (not (verbose or debug)):
            print()
            print(
                "{CYAN}  Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}"
                .format(**Init.Foreground))
        Exit.exit(1)

    except EnvironmentException as ex:
        Exit.printEnvironmentException(ex)
    except NotConfiguredException as ex:
        Exit.printNotConfiguredException(ex)
    except PlatformNotSupportedException as ex:
        Exit.printPlatformNotSupportedException(ex)
    except ExceptionBase as ex:
        Exit.printExceptionBase(ex)
    except NotImplementedError as ex:
        Exit.printNotImplementedError(ex)
    except ImportError as ex:
        printImportError(ex)
    except Exception as ex:
        Exit.printException(ex)
Exemple #19
0
#    
#
# License:
# ==============================================================================
# Copyright 2007-2016 Technische Universitaet Dresden - Germany
#                     Chair for VLSI-Design, Diagnostics and Architecture
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Repository Service Tool")

# load dependencies

Exemple #20
0
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("PoC Library - Python Module ToolChains.Xilinx.ISE")


from subprocess            import check_output

from Base.Configuration          import Configuration as BaseConfiguration, ConfigurationException
from Base.Exceptions            import PlatformNotSupportedException
from Base.Executable            import Executable
from Base.Executable            import ExecutableArgument, ShortFlagArgument, ShortTupleArgument, StringArgument, CommandLineArgumentList
from Base.Logging                import LogEntry, Severity
from Base.Project                import Project as BaseProject, ProjectFile, ConstraintFile, FileTypes
from Base.Simulator              import SimulationResult, PoCSimulationResultFilter
from ToolChains.Xilinx.Xilinx    import XilinxException
from lib.Functions              import CallByRefParam

Exemple #21
0
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module  ToolChains.Aldec.Aldec")


from Base.Configuration    import Configuration as BaseConfiguration
from Base.ToolChain        import ToolChainException


class AldecException(ToolChainException):
	pass


class Configuration(BaseConfiguration):
	_vendor =      "Aldec"
	_toolName =    None  # automatically configure only vendor path
	_section  =    "INSTALL.Aldec"
	_template = {
Exemple #22
0
#		http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Class Compiler(PoCCompiler)")

# load dependencies
from pathlib import Path

from Base.Exceptions import *
from Compiler.Base import PoCCompiler 
from Compiler.Exceptions import *

class Compiler(PoCCompiler):

	__executables = {}

	def __init__(self, host, showLogs, showReport):
		super(self.__class__, self).__init__(host, showLogs, showReport)
Exemple #23
0
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("PoC Library - Python Module ToolChains.GHDL")


from pathlib                import Path
from re                     import compile as RegExpCompile
from subprocess             import check_output, CalledProcessError

from Base.Configuration     import Configuration as BaseConfiguration, ConfigurationException
from Base.Exceptions        import PlatformNotSupportedException
from Base.Executable        import Executable
from Base.Executable        import ExecutableArgument, PathArgument, StringArgument, ValuedFlagListArgument
from Base.Executable        import ShortFlagArgument, LongFlagArgument, ShortValuedFlagArgument, CommandLineArgumentList
from Base.Logging           import LogEntry, Severity
from Base.Simulator         import PoCSimulationResultFilter, SimulationResult
from Base.ToolChain         import ToolChainException
from lib.Functions          import CallByRefParam
Exemple #24
0
#		http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module Simulator.GHDLSimulator")

# load dependencies
from pathlib import Path

from Base.Exceptions import *
from Simulator.Base import PoCSimulator 
from Simulator.Exceptions import * 

class Simulator(PoCSimulator):

	__executables =		{}
	__vhdlStandard =	"93"
	__guiMode =				False

	def __init__(self, host, showLogs, showReport, vhdlStandard, guiMode):
Exemple #25
0
#		http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module Processor.Base")

# load dependencies
from Base.Exceptions import *

class PoCProcessor(object):
	__host = None
	__debug = False
	__verbose = False
	__quiet = False
	showLogs = False
	showReport = False
	dryRun = False

	def __init__(self, host, showLogs, showReport):
		self.__debug = host.getDebug()
Exemple #26
0
		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)
			
# entry point
if __name__ == "__main__":
	Exit.versionCheck((3,4,0))
	main()
else:
	Exit.printThisIsNoLibraryFile(Netlist.headLine)
Exemple #27
0
#		http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module Base.PoCBase")

# load dependencies
from pathlib import Path
from Base.Exceptions import *

class CommandLineProgram(object):
	import platform
	
	# configure hard coded variables here
	__scriptDirectoryName = 			"py"
	__pocPrivateConfigFileName =	"config.private.ini"
	__pocPublicConfigFileName =		"config.public.ini"


	# private fields
Exemple #28
0
				print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause= str(cause), **Init.Foreground))
		elif isinstance(cause, ToolChainException):
			print("{YELLOW}  {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			cause = cause.__cause__
			if (cause is not None):
				if isinstance(cause, OSError):
					print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			else:
				print("  Possible causes:")
				print("   - The compile order is broken.")
				print("   - A source file was not compiled and an old file got used.")

		if (not (verbose or debug)):
			print()
			print("{CYAN}  Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}".format(**Init.Foreground))
		Exit.exit(1)

	except EnvironmentException as ex:          Exit.printEnvironmentException(ex)
	except NotConfiguredException as ex:        Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex:  Exit.printPlatformNotSupportedException(ex)
	except ExceptionBase as ex:                  Exit.printExceptionbase(ex)
	except NotImplementedError as ex:            Exit.printNotImplementedError(ex)
	# except Exception as ex:                      Exit.printException(ex)

# entry point
if __name__ == "__main__":
	Exit.versionCheck((3,5,0))
	main()
else:
	Exit.printThisIsNoLibraryFile(PoC.HeadLine)
Exemple #29
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
from Base.Exceptions import PlatformNotSupportedException


if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("The PoC-Library - Python Module Compiler.XSTCompiler")


# load dependencies
from pathlib                      import Path

from Base.Compiler                import Compiler as BaseCompiler, CompilerException, SkipableCompilerException
from Base.Project                 import ToolChain, Tool
from PoC.Entity                   import WildCard
from ToolChains.Lattice.Diamond   import Diamond, SynthesisArgumentFile
from ToolChains.Lattice.Lattice import LatticeException


class Compiler(BaseCompiler):
	_TOOL_CHAIN =  ToolChain.Lattice_Diamond
	_TOOL =        Tool.Lattice_LSE
Exemple #30
0
def main():
	dryRun =  "-D" in sys_argv
	debug =    "-d" in sys_argv
	verbose =  "-v" in sys_argv
	quiet =    "-q" in sys_argv

	# configure Exit class
	Exit.quiet = quiet

	try:
		Init.init()
		# handover to a class instance
		poc = PoC(debug, verbose, quiet, dryRun)
		poc.Run()
		Exit.exit()

	except (CommonException, ConfigurationException, SimulatorException, CompilerException) as ex:
		print("{RED}ERROR:{NOCOLOR} {message}".format(message=ex.message, **Init.Foreground))
		cause = ex.__cause__
		if isinstance(cause, FileNotFoundError):
			print("{YELLOW}  FileNotFound:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, NotADirectoryError):
			print("{YELLOW}  NotADirectory:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, DuplicateOptionError):
			print("{YELLOW}  DuplicateOptionError:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, ConfigParser_Error):
			print("{YELLOW}  configparser.Error:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, ParserException):
			print("{YELLOW}  ParserException:{NOCOLOR} {cause}".format(cause=str(cause), **Init.Foreground))
			cause = cause.__cause__
			if (cause is not None):
				print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause= str(cause), **Init.Foreground))
		elif isinstance(cause, ToolChainException):
			print("{YELLOW}  {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			cause = cause.__cause__
			if (cause is not None):
				if isinstance(cause, OSError):
					print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			else:
				print("  Possible causes:")
				print("   - The compile order is broken.")
				print("   - A source file was not compiled and an old file got used.")

		if (not (verbose or debug)):
			print()
			print("{CYAN}  Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}".format(**Init.Foreground))
		Exit.exit(1)

	except EnvironmentException as ex:          Exit.printEnvironmentException(ex)
	except NotConfiguredException as ex:        Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex:  Exit.printPlatformNotSupportedException(ex)
	except ExceptionBase as ex:                  Exit.printExceptionbase(ex)
	except NotImplementedError as ex:            Exit.printNotImplementedError(ex)
Exemple #31
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# entry point
import time


if __name__ != "__main__":
	# place library initialization code here
	pass
else:
	from lib.Functions import Exit
	Exit.printThisIsNoExecutableFile("PoC Library - Python Module ToolChains.Lattice.Diamond")

from pathlib import Path
from subprocess                    import check_output, CalledProcessError, STDOUT

from Base.Configuration            import Configuration as BaseConfiguration, ConfigurationException
from Base.Exceptions              import PlatformNotSupportedException
from Base.Executable              import Executable, CommandLineArgumentList, ExecutableArgument, ShortTupleArgument
from Base.Logging                  import Severity, LogEntry
from Base.Project                  import File, FileTypes
from ToolChains.Lattice.Lattice    import LatticeException


class DiamondException(LatticeException):
	pass
Exemple #32
0
                    "   - A source file was not compiled and an old file got used."
                )

        if (not (verbose or debug)):
            print()
            print(
                "{CYAN}  Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}"
                .format(**Init.Foreground))
        Exit.exit(1)

    except EnvironmentException as ex:
        Exit.printEnvironmentException(ex)
    except NotConfiguredException as ex:
        Exit.printNotConfiguredException(ex)
    except PlatformNotSupportedException as ex:
        Exit.printPlatformNotSupportedException(ex)
    except ExceptionBase as ex:
        Exit.printExceptionBase(ex)
    except NotImplementedError as ex:
        Exit.printNotImplementedError(ex)
    except ImportError as ex:
        printImportError(ex)
    except Exception as ex:
        Exit.printException(ex)


# entry point
if __name__ == "__main__":
    Exit.versionCheck((3, 5, 0))
    main()