build.plat: add default_clk{,_constraint,_frequency}.

This is the equivalent of oMigen's default_clk and default_clk_period
except the period is taken from the resource.
This commit is contained in:
whitequark 2019-08-03 16:18:46 +00:00
parent cea92e9531
commit 4dbb5352ad

View file

@ -20,6 +20,7 @@ __all__ = ["Platform", "TemplatedPlatform"]
class Platform(ResourceManager, metaclass=ABCMeta):
resources = abstractproperty()
connectors = abstractproperty()
default_clk = None
def __init__(self):
super().__init__(self.resources, self.connectors)
@ -28,6 +29,21 @@ class Platform(ResourceManager, metaclass=ABCMeta):
self._prepared = False
@property
def default_clk_constraint(self):
if self.default_clk is None:
raise AttributeError("Platform '{}' does not define a default clock"
.format(self.__class__.__name__))
return self.lookup(self.default_clk).clock
@property
def default_clk_frequency(self):
constraint = self.default_clk_constraint
if constraint is None:
raise AttributeError("Platform '{}' does not constrain its default clock"
.format(self.__class__.__name__))
return constraint.frequency
def add_file(self, filename, content):
if not isinstance(filename, str):
raise TypeError("File name must be a string")