diff --git a/litex/build/altera/platform.py b/litex/build/altera/platform.py index a95dcf4b9..2f03fc720 100644 --- a/litex/build/altera/platform.py +++ b/litex/build/altera/platform.py @@ -33,6 +33,7 @@ class AlteraPlatform(GenericPlatform): return self.toolchain.build(self, *args, **kwargs) def add_period_constraint(self, clk, period): + if clk is None: return if hasattr(clk, "p"): clk = clk.p self.toolchain.add_period_constraint(self, clk, period) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index d540cc38a..7c489efea 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -205,13 +205,21 @@ class ConstraintManager: self.matched.append((resource, obj)) return obj - def lookup_request(self, name, number=None): + def lookup_request(self, name, number=None, loose=False): + subname = None + if ":" in name: name, subname = name.split(":") for resource, obj in self.matched: if resource[0] == name and (number is None or resource[1] == number): - return obj + if subname is not None: + return getattr(obj, subname) + else: + return obj - raise ConstraintError("Resource not found: {}:{}".format(name, number)) + if loose: + return None + else: + raise ConstraintError("Resource not found: {}:{}".format(name, number)) def add_platform_command(self, command, **signals): self.platform_commands.append((command, signals)) diff --git a/litex/build/lattice/platform.py b/litex/build/lattice/platform.py index 71ff2a653..7380b45e0 100644 --- a/litex/build/lattice/platform.py +++ b/litex/build/lattice/platform.py @@ -34,6 +34,7 @@ class LatticePlatform(GenericPlatform): return self.toolchain.build(self, *args, **kwargs) def add_period_constraint(self, clk, period): + if clk is None: return if hasattr(clk, "p"): clk = clk.p self.toolchain.add_period_constraint(self, clk, period) diff --git a/litex/build/microsemi/platform.py b/litex/build/microsemi/platform.py index 65d2c996d..c8f13bd89 100644 --- a/litex/build/microsemi/platform.py +++ b/litex/build/microsemi/platform.py @@ -28,6 +28,7 @@ class MicrosemiPlatform(GenericPlatform): return self.toolchain.build(self, *args, **kwargs) def add_period_constraint(self, clk, period): + if clk is None: return clk.attr.add("keep") if hasattr(clk, "p"): clk = clk.p diff --git a/litex/build/xilinx/platform.py b/litex/build/xilinx/platform.py index cf7bbeb50..d5e3d8f85 100644 --- a/litex/build/xilinx/platform.py +++ b/litex/build/xilinx/platform.py @@ -48,6 +48,7 @@ class XilinxPlatform(GenericPlatform): return self.toolchain.build(self, *args, **kwargs) def add_period_constraint(self, clk, period): + if clk is None: return if hasattr(clk, "p"): clk = clk.p self.toolchain.add_period_constraint(self, clk, period)