Commit c79d7b83 authored by Will Kamp's avatar Will Kamp

Fix Architecture and Entity dependencies so that files listed in correct order.

For the case when the entity and architecture are in different files (because you have multiple architectures). Added architecture dependency type. Now architectures depend on entities, instances depend on architectures. Dependency key is only library.entity so will probably not work if analysing multiple architectures for an entity.
parent a3f01e86
......@@ -34,10 +34,11 @@ class DepRelation(object):
ENTITY = 1
PACKAGE = 2
INCLUDE = 3
ARCHITECTURE = 4
def __init__(self, obj_name, direction, rel_type):
assert direction in [DepRelation.PROVIDE, DepRelation.USE]
assert rel_type in [DepRelation.ENTITY, DepRelation.PACKAGE, DepRelation.INCLUDE]
assert rel_type in [DepRelation.ENTITY, DepRelation.PACKAGE, DepRelation.INCLUDE, DepRelation.ARCHITECTURE]
self.direction = direction
self.rel_type = rel_type
self.obj_name = obj_name
......@@ -62,7 +63,7 @@ class DepRelation(object):
def __repr__(self):
dstr = {self.USE: "Use", self.PROVIDE: "Provide"}
ostr = {self.ENTITY: "entity/module", self.PACKAGE: "package", self.INCLUDE: "include/header"}
ostr = {self.ENTITY: "entity/module", self.PACKAGE: "package", self.INCLUDE: "include/header", self.ARCHITECTURE: "architecture"}
return "%s %s '%s'" % (dstr[self.direction], ostr[self.rel_type], self.obj_name)
def __hash__(self):
......
......@@ -89,6 +89,9 @@ class VHDLParser(DepParser):
dep_file.add_relation(DepRelation("%s.%s" % (dep_file.library, s.group(2).lower()),
DepRelation.USE,
DepRelation.ENTITY))
dep_file.add_relation(DepRelation("%s.%s" % (dep_file.library, s.group(2).lower()),
DepRelation.PROVIDE,
DepRelation.ARCHITECTURE))
re.subn(architecture_pattern, do_architecture, buf)
#new package
......@@ -109,18 +112,18 @@ class VHDLParser(DepParser):
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))
DepRelation.ARCHITECTURE))
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))
DepRelation.ARCHITECTURE))
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))
DepRelation.ARCHITECTURE))
re.subn(instance_pattern, do_instance, buf)
re.subn(instance_from_library_pattern, do_instance_from_library, 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