Beispiel #1
0
    def __init__(  # pylint: disable=too-many-arguments
        self,
        file_type,
        name,
        library,
        verilog_parser,
        database,
        include_dirs=None,
        defines=None,
        no_parse=False,
    ):
        SourceFile.__init__(self, name, library, file_type)
        self.package_dependencies = []
        self.module_dependencies = []
        self.include_dirs = include_dirs if include_dirs is not None else []
        self.defines = defines.copy() if defines is not None else {}
        self._content_hash = file_content_hash(self.name,
                                               encoding=HDL_FILE_ENCODING,
                                               database=database)

        for path in self.include_dirs:
            self._content_hash = hash_string(self._content_hash +
                                             hash_string(path))

        for key, value in sorted(self.defines.items()):
            self._content_hash = hash_string(self._content_hash +
                                             hash_string(key))
            self._content_hash = hash_string(self._content_hash +
                                             hash_string(value))

        if not no_parse:
            self.parse(verilog_parser, database, include_dirs)
Beispiel #2
0
    def __init__(  # pylint: disable=too-many-arguments
            self,
            name,
            library,
            vhdl_parser,
            database,
            vhdl_standard,
            no_parse=False):
        SourceFile.__init__(self, name, library, "vhdl")
        self.dependencies = []
        self.depending_components = []
        self._vhdl_standard = vhdl_standard

        if not no_parse:

            try:
                design_file = vhdl_parser.parse(self.name)
            except KeyboardInterrupt:
                raise KeyboardInterrupt
            except:  # pylint: disable=bare-except
                traceback.print_exc()
                LOGGER.error("Failed to parse %s", self.name)
            else:
                self._add_design_file(design_file)

        self._content_hash = file_content_hash(self.name,
                                               encoding=HDL_FILE_ENCODING,
                                               database=database)
Beispiel #3
0
    def parse(self, parser, database, include_dirs):
        """
        Parse Verilog code and adding dependencies and design units
        """
        try:
            design_file = parser.parse(self.name, include_dirs, self.defines)
            for included_file_name in design_file.included_files:
                self._content_hash = hash_string(self._content_hash
                                                 + file_content_hash(included_file_name,
                                                                     encoding=HDL_FILE_ENCODING,
                                                                     database=database))

            for module in design_file.modules:
                self.design_units.append(Module(module.name, self, module.parameters))

            for package in design_file.packages:
                self.design_units.append(DesignUnit(package.name, self, "package"))

            for package_name in design_file.imports:
                self.package_dependencies.append(package_name)

            for package_name in design_file.package_references:
                self.package_dependencies.append(package_name)

            for instance_name in design_file.instances:
                self.module_dependencies.append(instance_name)

        except KeyboardInterrupt:
            raise KeyboardInterrupt
        except:  # pylint: disable=bare-except
            traceback.print_exc()
            LOGGER.error("Failed to parse %s", self.name)
Beispiel #4
0
    def parse(self, parser, database, include_dirs):
        """
        Parse Verilog code and adding dependencies and design units
        """
        try:
            design_file = parser.parse(self.name, include_dirs, self.defines)
            for included_file_name in design_file.included_files:
                self._content_hash = hash_string(
                    self._content_hash +
                    file_content_hash(included_file_name,
                                      encoding=HDL_FILE_ENCODING,
                                      database=database))
            for module in design_file.modules:
                self.design_units.append(
                    Module(module.name, self, module.parameters))

            for package in design_file.packages:
                self.design_units.append(
                    DesignUnit(package.name, self, "package"))

            for package_name in design_file.imports:
                self.package_dependencies.append(package_name)

            for package_name in design_file.package_references:
                self.package_dependencies.append(package_name)

            for instance_name in design_file.instances:
                self.module_dependencies.append(instance_name)

        except KeyboardInterrupt:
            raise
        except:  # pylint: disable=bare-except
            traceback.print_exc()
            LOGGER.error("Failed to parse %s", self.name)
Beispiel #5
0
 def _content_hash(self, file_name):
     """
     Hash the contents of the file
     """
     if file_name is None or not exists(file_name):
         return None
     if file_name not in self._content_cache:
         self._content_cache[file_name] = file_content_hash(
             file_name, encoding=HDL_FILE_ENCODING, database=self._database)
     return self._content_cache[file_name]
Beispiel #6
0
 def _content_hash(self, file_name):
     """
     Hash the contents of the file
     """
     if file_name is None or not exists(file_name):
         return None
     if file_name not in self._content_cache:
         self._content_cache[file_name] = file_content_hash(file_name,
                                                            encoding=HDL_FILE_ENCODING,
                                                            database=self._database)
     return self._content_cache[file_name]
Beispiel #7
0
    def __init__(self,  # pylint: disable=too-many-arguments
                 name, library, vhdl_parser, database, vhdl_standard, no_parse=False):
        SourceFile.__init__(self, name, library, 'vhdl')
        self.dependencies = []
        self.depending_components = []
        self._vhdl_standard = vhdl_standard
        check_vhdl_standard(vhdl_standard)

        if not no_parse:
            design_file = vhdl_parser.parse(self.name)
            self._add_design_file(design_file)

        self._content_hash = file_content_hash(self.name,
                                               encoding=HDL_FILE_ENCODING,
                                               database=database)
Beispiel #8
0
    def __init__(self,  # pylint: disable=too-many-arguments
                 file_type, name, library, verilog_parser, database, include_dirs=None, defines=None, no_parse=False):
        SourceFile.__init__(self, name, library, file_type)
        self.package_dependencies = []
        self.module_dependencies = []
        self.include_dirs = include_dirs if include_dirs is not None else []
        self.defines = defines.copy() if defines is not None else {}
        self._content_hash = file_content_hash(self.name, encoding=HDL_FILE_ENCODING,
                                               database=database)

        for path in self.include_dirs:
            self._content_hash = hash_string(self._content_hash + hash_string(path))

        for key, value in sorted(self.defines.items()):
            self._content_hash = hash_string(self._content_hash + hash_string(key))
            self._content_hash = hash_string(self._content_hash + hash_string(value))

        if not no_parse:
            self.parse(verilog_parser, database, include_dirs)
Beispiel #9
0
    def __init__(self,  # pylint: disable=too-many-arguments
                 name, library, vhdl_parser, database, vhdl_standard, no_parse=False):
        SourceFile.__init__(self, name, library, 'vhdl')
        self.dependencies = []
        self.depending_components = []
        self._vhdl_standard = vhdl_standard
        check_vhdl_standard(vhdl_standard)

        if not no_parse:

            try:
                design_file = vhdl_parser.parse(self.name)
            except KeyboardInterrupt:
                raise KeyboardInterrupt
            except:  # pylint: disable=bare-except
                traceback.print_exc()
                LOGGER.error("Failed to parse %s", self.name)
            else:
                self._add_design_file(design_file)

        self._content_hash = file_content_hash(self.name,
                                               encoding=HDL_FILE_ENCODING,
                                               database=database)