build/platform: allow doing a loose lookup_request (return None instead of ConstraintError) and allow subname in lookup_request.
In the platforms, insead of doing: self.lookup_request("eth_clocks").rx we can now do: self.lookup_request("eth_clocks:rx") This allows some try/except simplifications on constraints.
This commit is contained in:
parent
b8f9f83a8f
commit
d0b8daa005
|
@ -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)
|
||||
|
|
|
@ -205,12 +205,20 @@ 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):
|
||||
if subname is not None:
|
||||
return getattr(obj, subname)
|
||||
else:
|
||||
return obj
|
||||
|
||||
if loose:
|
||||
return None
|
||||
else:
|
||||
raise ConstraintError("Resource not found: {}:{}".format(name, number))
|
||||
|
||||
def add_platform_command(self, command, **signals):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue