Commit 033590e1 authored by William Kamp's avatar William Kamp Committed by Javier D. Garcia-Lasheras

Better support multiple VHDL libraries.

VHDL_parser.py extracts the library from instantiations.
new_dep_solver.py does not assume the work library.
core.py inherits the library from the parent Manifest.
parent 26f08930
...@@ -52,10 +52,10 @@ class ModuleContent(ModuleCore): ...@@ -52,10 +52,10 @@ class ModuleContent(ModuleCore):
def process_manifest(self): def process_manifest(self):
"""Process the content section of the manifest_dic""" """Process the content section of the manifest_dic"""
super(ModuleContent, self).process_manifest()
self._process_manifest_files() self._process_manifest_files()
self._process_manifest_modules() self._process_manifest_modules()
self._process_manifest_makefiles() self._process_manifest_makefiles()
super(ModuleContent, self).process_manifest()
def _process_manifest_files(self): def _process_manifest_files(self):
"""Process the files instantiated by the HDLMake module""" """Process the files instantiated by the HDLMake module"""
...@@ -71,8 +71,10 @@ class ModuleContent(ModuleCore): ...@@ -71,8 +71,10 @@ class ModuleContent(ModuleCore):
else: else:
self.manifest_dict["files"] = path_mod.flatten_list( self.manifest_dict["files"] = path_mod.flatten_list(
self.manifest_dict["files"]) self.manifest_dict["files"])
logging.debug("Files in %s: %s", logging.debug("Files in %s: %s to library %s" ,
self.path, str(self.manifest_dict["files"])) self.path,
str(self.manifest_dict["files"]),
self.library)
paths = self._make_list_of_paths(self.manifest_dict["files"]) paths = self._make_list_of_paths(self.manifest_dict["files"])
self.files = self._create_file_list_from_paths(paths=paths) self.files = self._create_file_list_from_paths(paths=paths)
......
...@@ -143,5 +143,8 @@ class ModuleCore(ModuleConfig): ...@@ -143,5 +143,8 @@ class ModuleCore(ModuleConfig):
# Libraries # Libraries
if "library" in self.manifest_dict: if "library" in self.manifest_dict:
self.library = self.manifest_dict["library"] self.library = self.manifest_dict["library"]
elif self.parent:
self.library = self.parent.library
if "action" in self.manifest_dict: if "action" in self.manifest_dict:
self.action = self.manifest_dict["action"].lower() self.action = self.manifest_dict["action"].lower()
...@@ -136,8 +136,8 @@ def make_dependency_set(fileset, top_level_entity, extra_modules=None): ...@@ -136,8 +136,8 @@ def make_dependency_set(fileset, top_level_entity, extra_modules=None):
def _check_entity(test_file, entity_name): def _check_entity(test_file, entity_name):
""" Check if the input file provides the entity pointed by the name""" """ Check if the input file provides the entity pointed by the name"""
entity_rel_vhdl = DepRelation( entity_rel_vhdl = DepRelation(
"%s.%s" % entity_name,
("work", entity_name), DepRelation.PROVIDE, DepRelation.ENTITY) DepRelation.PROVIDE, DepRelation.ENTITY)
entity_rel_vlog = DepRelation( entity_rel_vlog = DepRelation(
"%s.%s" % "%s.%s" %
("work", entity_name), DepRelation.PROVIDE, DepRelation.MODULE) ("work", entity_name), DepRelation.PROVIDE, DepRelation.MODULE)
......
...@@ -248,7 +248,10 @@ class VHDLParser(DepParser): ...@@ -248,7 +248,10 @@ class VHDLParser(DepParser):
# instantions # instantions
libraries = set([dep_file.library]) libraries = set([dep_file.library])
instance_pattern = re.compile( instance_pattern = re.compile(
r"^\s*(\w+)\s*:\s*(?:entity\s+\w+\.)?(\w+)\s*(?:\(\s*\w+\s*\)\s*)?(?:port\s+map.*?|generic\s+map.*?)", r"^\s*(?P<LABEL>\w+)\s*:"
r"\s*(?:entity\s+(?P<LIB>\w+)\.)?(?P<ENTITY>\w+)"
r"\s*(?:\(\s*(?P<ARCH>\w+)\s*\)\s*)?"
r"(?:port\s+map.*?|generic\s+map.*?)",
re.DOTALL | re.MULTILINE | re.IGNORECASE) re.DOTALL | re.MULTILINE | re.IGNORECASE)
def do_instance(text): def do_instance(text):
...@@ -256,14 +259,17 @@ class VHDLParser(DepParser): ...@@ -256,14 +259,17 @@ class VHDLParser(DepParser):
instance_pattern in the VHDL code -- group() returns positive instance_pattern in the VHDL code -- group() returns positive
matches as indexed plain strings. It adds the found USE matches as indexed plain strings. It adds the found USE
relations to the file""" relations to the file"""
for lib in libraries: logging.debug("-> instantiates %s.%s(%s) as %s",
logging.debug("-> instantiates %s.%s as %s", text.group("LIB"), text.group("ENTITY"), text.group("ARCH"), text.group("LABEL"))
lib, text.group(2), text.group(1)) lib = text.group("LIB")
dep_file.add_relation(DepRelation( if not lib or lib == "work":
"%s.%s" % (lib, text.group(2)), lib = dep_file.library
DepRelation.USE, DepRelation.ENTITY)) dep_file.add_relation(DepRelation(
return "<hdlmake instance %s|%s>" % (text.group(1), "%s.%s" % (lib, text.group("ENTITY")),
text.group(2)) DepRelation.USE, DepRelation.ENTITY))
return "<hdlmake instance %s|%s|%s>" % (text.group("LABEL"),
lib,
text.group("ENTITY"))
buf = re.sub(instance_pattern, do_instance, buf) buf = re.sub(instance_pattern, do_instance, buf)
instance_from_library_pattern = re.compile( instance_from_library_pattern = re.compile(
......
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