Commit ae3eb417 authored by Adrian Fiergolski's avatar Adrian Fiergolski Committed by Javier D. Garcia Lasheras

Fix bug 1008: The vlog_parser checks if any packages are used by a source file...

Fix bug 1008: The vlog_parser checks if any packages are used by a source file and in case adds them to file's dependencies.
parent 7a156c94
......@@ -2,6 +2,7 @@
# Copyright (c) 2013 CERN
# Author: Tomasz Wlostowski
# Adrian Fiergolski
# This file is part of Hdlmake.
......@@ -549,19 +550,41 @@ class VerilogParser(DepParser):
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 package" %( dep_file.path , ) )
dep_file.add_relation(DepRelation(, DepRelation.USE, DepRelation.PACKAGE))
re.subn(import_pattern, do_imports, buf)
m_inside_package = re.compile("package\s+(\w+)\s*(?:\(.*?\))?\s*(.+?)endpackage", re.DOTALL | re.MULTILINE)
def do_package(s):
logging.debug("found pacakge %s"
dep_file.add_relation(DepRelation(, 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):
# print("module %s"
logging.debug("found module %s"
dep_file.add_relation(DepRelation(, DepRelation.PROVIDE, DepRelation.ENTITY))
def do_inst(s):
mod_name =
if(mod_name in self.reserved_words):
# print("-> instantiates %s as %s" % (,
logging.debug("-> instantiates %s as %s" % (, ))
dep_file.add_relation(DepRelation(, DepRelation.USE, DepRelation.ENTITY))
re.subn(m_instantiation, do_inst,
re.subn(m_inside_module, do_module, buf)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment