Example #1
0
 def do_use(s):
     if (s.group(1).lower() == "work"
         ):  #work is the current library in VHDL
         logging.debug("use package %s.%s" %
                       (dep_file.library, s.group(2)))
         dep_file.add_relation(
             DepRelation(
                 "%s.%s" % (dep_file.library, s.group(2).lower()),
                 DepRelation.USE, DepRelation.PACKAGE))
     else:
         logging.debug("use package %s.%s" % (s.group(1), s.group(2)))
         dep_file.add_relation(
             DepRelation(
                 "%s.%s" % (s.group(1).lower(), s.group(2).lower()),
                 DepRelation.USE, DepRelation.PACKAGE))
Example #2
0
 def do_instance_from_library(s):
     if (s.group(2).lower() == "work"
         ):  #work is the current library in VHDL
         logging.debug("-> instantiates %s.%s as %s" %
                       (dep_file.library, s.group(3), s.group(1)))
         dep_file.add_relation(
             DepRelation(
                 "%s.%s" % (dep_file.library, s.group(3).lower()),
                 DepRelation.USE, DepRelation.ENTITY))
     else:
         logging.debug("-> instantiates %s.%s as %s" %
                       (s.group(2), s.group(3), s.group(1)))
         dep_file.add_relation(
             DepRelation(
                 "%s.%s" % (s.group(2).lower(), s.group(3).lower()),
                 DepRelation.USE, DepRelation.ENTITY))
Example #3
0
 def do_instance(s):
     for lib in libraries:
         logging.debug("-> instantiates %s.%s as %s" %
                       (lib, s.group(2), s.group(1)))
         dep_file.add_relation(
             DepRelation("%s.%s" % (lib, s.group(2).lower()),
                         DepRelation.USE, DepRelation.ENTITY))
Example #4
0
    def parse(self, dep_file):
        i = 0;
        if dep_file.is_parsed:
            return
        logging.info("Parsing %s" % dep_file.path)
        # assert isinstance(dep_file, DepFile), print("unexpected type: " + str(type(dep_file)))
        buf = self.preprocessor.preprocess(dep_file)
        self.preprocessed = buf[:]

        #add includes as dependencies
        try:
            includes = self.preprocessor.vpp_filedeps[dep_file.path + dep_file.library]
            for f in includes:
                dep_file.depends_on.add(SourceFileFactory().new(path=f, module=dep_file.module))
            logging.debug( "%s has %d includes." % (str(dep_file), len(includes)))
        except KeyError:
            logging.debug(str(dep_file) + " has no includes.")
         
        #look for packages used inside in file
        #it may generate false dependencies as package in SV can be used by:
        #    import my_package::*;
        #or directly
        #    logic var = my_package::MY_CONST;
        #The same way constants and others can be imported directly from other modules:
        #    logic var = my_other_module::MY_CONST;
        #and HdlMake will anyway create dependency marking my_other_module as requested package
        import_pattern = re.compile("(\w+) *::(\w+|\\*)")
        def do_imports(s):
            logging.debug("file %s imports/uses %s.%s package" %( dep_file.path , dep_file.library, s.group(1) ) )
            dep_file.add_relation( DepRelation( "%s.%s" % (dep_file.library, s.group(1)) , DepRelation.USE, DepRelation.PACKAGE))
        re.subn(import_pattern, do_imports, buf)
        
        #packages
        m_inside_package = re.compile("package\s+(\w+)\s*(?:\(.*?\))?\s*(.+?)endpackage", re.DOTALL | re.MULTILINE)
        def do_package(s):
            logging.debug("found pacakge %s.%s" %(dep_file.library, s.group(1)) )
            dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.PROVIDE, DepRelation.PACKAGE))
        re.subn(m_inside_package, do_package, buf)

        #modules and instatniations
        m_inside_module = re.compile("(?:module|interface)\s+(\w+)\s*(?:\(.*?\))?\s*(.+?)(?:endmodule|endinterface)", re.DOTALL | re.MULTILINE)
        m_instantiation = re.compile("(?:\A|\\s*)\s*(\w+)\s+(?:#\s*\(.*?\)\s*)?(\w+)\s*\(.*?\)\s*", re.DOTALL | re.MULTILINE)

        def do_module(s):
            logging.debug("found module %s.%s" % (dep_file.library, s.group(1) ))
            dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.PROVIDE, DepRelation.ENTITY))

            def do_inst(s):
                mod_name = s.group(1)
                if(mod_name in self.reserved_words):
                    return
                logging.debug("-> instantiates %s.%s as %s" % (dep_file.library, s.group(1), s.group(2) ))
                dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.USE, DepRelation.ENTITY))
            re.subn(m_instantiation, do_inst, s.group(2))
        re.subn(m_inside_module, do_module,  buf)

        dep_file.add_relation(DepRelation(dep_file.path, DepRelation.PROVIDE, DepRelation.INCLUDE))
        dep_file.is_parsed = True
Example #5
0
        def do_module(s):
            logging.debug("found module %s.%s" % (dep_file.library, s.group(1) ))
            dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.PROVIDE, DepRelation.ENTITY))

            def do_inst(s):
                mod_name = s.group(1)
                if(mod_name in self.reserved_words):
                    return
                logging.debug("-> instantiates %s.%s as %s" % (dep_file.library, s.group(1), s.group(2) ))
                dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.USE, DepRelation.ENTITY))
            re.subn(m_instantiation, do_inst, s.group(2))
Example #6
0
 def do_package(s):
     logging.debug("found pacakge %s.%s" %(dep_file.library, s.group(1)) )
     dep_file.add_relation(DepRelation( "%s.%s" % (dep_file.library, s.group(1)), DepRelation.PROVIDE, DepRelation.PACKAGE))
Example #7
0
 def do_imports(s):
     logging.debug("file %s imports/uses %s.%s package" %( dep_file.path , dep_file.library, s.group(1) ) )
     dep_file.add_relation( DepRelation( "%s.%s" % (dep_file.library, s.group(1)) , DepRelation.USE, DepRelation.PACKAGE))
Example #8
0
 def do_entity(s):
     logging.debug("found entity %s.%s" %
                   (dep_file.library, s.group(1)))
     dep_file.add_relation(
         DepRelation("%s.%s" % (dep_file.library, s.group(1).lower()),
                     DepRelation.PROVIDE, DepRelation.ENTITY))