From: Florent Kermarrec Date: Sat, 6 Jan 2018 00:33:02 +0000 (+0100) Subject: build: add Inverted property to IOs to ease inverting signals and propagate property... X-Git-Tag: 24jan2021_ls180~1772 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee6b33e9d3bcfbbdea9709de4bb6670ae6721211;p=litex.git build: add Inverted property to IOs to ease inverting signals and propagate property to cores --- diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 226bc9a4..1ab5935e 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -49,6 +49,12 @@ class Misc: return "{}({})".format(self.__class__.__name__, repr(self.misc)) +class Inverted: + def __repr__(self): + return "{}()".format(self.__class__.__name__) + + + class Subsignal: def __init__(self, name, *constraints): self.name = name @@ -78,6 +84,7 @@ def _lookup(description, name, number): def _resource_type(resource): t = None + i = None for element in resource[2:]: if isinstance(element, Pins): assert(t is None) @@ -85,17 +92,23 @@ def _resource_type(resource): elif isinstance(element, Subsignal): if t is None: t = [] + if i is None: + i = [] assert(isinstance(t, list)) n_bits = None + inverted = False for c in element.constraints: if isinstance(c, Pins): assert(n_bits is None) n_bits = len(c.identifiers) + if isinstance(c, Inverted): + inverted = True t.append((element.name, n_bits)) + i.append((element.name, inverted)) - return t + return t, i class ConnectorManager: @@ -160,7 +173,7 @@ class ConstraintManager: def request(self, name, number=None): resource = _lookup(self.available, name, number) - rt = _resource_type(resource) + rt, ri = _resource_type(resource) if number is None: resource_name = name else: @@ -169,8 +182,14 @@ class ConstraintManager: obj = Signal(rt, name_override=resource_name) else: obj = Record(rt, name=resource_name) + for name, inverted in ri: + if inverted: + getattr(obj, name).inverted = True for element in resource[2:]: + if isinstance(element, Inverted): + if isinstance(obj, Signal): + obj.inverted = True if isinstance(element, PlatformInfo): obj.platform_info = element.info break diff --git a/litex/build/xilinx/vivado.py b/litex/build/xilinx/vivado.py index b626328e..4b9fedfa 100644 --- a/litex/build/xilinx/vivado.py +++ b/litex/build/xilinx/vivado.py @@ -20,6 +20,8 @@ def _format_constraint(c): return "set_property DRIVE " + str(c.strength) elif isinstance(c, Misc): return "set_property " + c.misc.replace("=", " ") + elif isinstance(c, Inverted): + return "" else: raise ValueError("unknown constraint {}".format(c))