build: add Inverted property to IOs to ease inverting signals and propagate property to cores
This commit is contained in:
parent
621aaf6988
commit
ee6b33e9d3
|
@ -49,6 +49,12 @@ class Misc:
|
||||||
return "{}({})".format(self.__class__.__name__, repr(self.misc))
|
return "{}({})".format(self.__class__.__name__, repr(self.misc))
|
||||||
|
|
||||||
|
|
||||||
|
class Inverted:
|
||||||
|
def __repr__(self):
|
||||||
|
return "{}()".format(self.__class__.__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Subsignal:
|
class Subsignal:
|
||||||
def __init__(self, name, *constraints):
|
def __init__(self, name, *constraints):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -78,6 +84,7 @@ def _lookup(description, name, number):
|
||||||
|
|
||||||
def _resource_type(resource):
|
def _resource_type(resource):
|
||||||
t = None
|
t = None
|
||||||
|
i = None
|
||||||
for element in resource[2:]:
|
for element in resource[2:]:
|
||||||
if isinstance(element, Pins):
|
if isinstance(element, Pins):
|
||||||
assert(t is None)
|
assert(t is None)
|
||||||
|
@ -85,17 +92,23 @@ def _resource_type(resource):
|
||||||
elif isinstance(element, Subsignal):
|
elif isinstance(element, Subsignal):
|
||||||
if t is None:
|
if t is None:
|
||||||
t = []
|
t = []
|
||||||
|
if i is None:
|
||||||
|
i = []
|
||||||
|
|
||||||
assert(isinstance(t, list))
|
assert(isinstance(t, list))
|
||||||
n_bits = None
|
n_bits = None
|
||||||
|
inverted = False
|
||||||
for c in element.constraints:
|
for c in element.constraints:
|
||||||
if isinstance(c, Pins):
|
if isinstance(c, Pins):
|
||||||
assert(n_bits is None)
|
assert(n_bits is None)
|
||||||
n_bits = len(c.identifiers)
|
n_bits = len(c.identifiers)
|
||||||
|
if isinstance(c, Inverted):
|
||||||
|
inverted = True
|
||||||
|
|
||||||
t.append((element.name, n_bits))
|
t.append((element.name, n_bits))
|
||||||
|
i.append((element.name, inverted))
|
||||||
|
|
||||||
return t
|
return t, i
|
||||||
|
|
||||||
|
|
||||||
class ConnectorManager:
|
class ConnectorManager:
|
||||||
|
@ -160,7 +173,7 @@ class ConstraintManager:
|
||||||
|
|
||||||
def request(self, name, number=None):
|
def request(self, name, number=None):
|
||||||
resource = _lookup(self.available, name, number)
|
resource = _lookup(self.available, name, number)
|
||||||
rt = _resource_type(resource)
|
rt, ri = _resource_type(resource)
|
||||||
if number is None:
|
if number is None:
|
||||||
resource_name = name
|
resource_name = name
|
||||||
else:
|
else:
|
||||||
|
@ -169,8 +182,14 @@ class ConstraintManager:
|
||||||
obj = Signal(rt, name_override=resource_name)
|
obj = Signal(rt, name_override=resource_name)
|
||||||
else:
|
else:
|
||||||
obj = Record(rt, name=resource_name)
|
obj = Record(rt, name=resource_name)
|
||||||
|
for name, inverted in ri:
|
||||||
|
if inverted:
|
||||||
|
getattr(obj, name).inverted = True
|
||||||
|
|
||||||
for element in resource[2:]:
|
for element in resource[2:]:
|
||||||
|
if isinstance(element, Inverted):
|
||||||
|
if isinstance(obj, Signal):
|
||||||
|
obj.inverted = True
|
||||||
if isinstance(element, PlatformInfo):
|
if isinstance(element, PlatformInfo):
|
||||||
obj.platform_info = element.info
|
obj.platform_info = element.info
|
||||||
break
|
break
|
||||||
|
|
|
@ -20,6 +20,8 @@ def _format_constraint(c):
|
||||||
return "set_property DRIVE " + str(c.strength)
|
return "set_property DRIVE " + str(c.strength)
|
||||||
elif isinstance(c, Misc):
|
elif isinstance(c, Misc):
|
||||||
return "set_property " + c.misc.replace("=", " ")
|
return "set_property " + c.misc.replace("=", " ")
|
||||||
|
elif isinstance(c, Inverted):
|
||||||
|
return ""
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown constraint {}".format(c))
|
raise ValueError("unknown constraint {}".format(c))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue