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:
parent
cea92e9531
commit
4dbb5352ad
|
@ -18,8 +18,9 @@ __all__ = ["Platform", "TemplatedPlatform"]
|
||||||
|
|
||||||
|
|
||||||
class Platform(ResourceManager, metaclass=ABCMeta):
|
class Platform(ResourceManager, metaclass=ABCMeta):
|
||||||
resources = abstractproperty()
|
resources = abstractproperty()
|
||||||
connectors = abstractproperty()
|
connectors = abstractproperty()
|
||||||
|
default_clk = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(self.resources, self.connectors)
|
super().__init__(self.resources, self.connectors)
|
||||||
|
@ -28,6 +29,21 @@ class Platform(ResourceManager, metaclass=ABCMeta):
|
||||||
|
|
||||||
self._prepared = False
|
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):
|
def add_file(self, filename, content):
|
||||||
if not isinstance(filename, str):
|
if not isinstance(filename, str):
|
||||||
raise TypeError("File name must be a string")
|
raise TypeError("File name must be a string")
|
||||||
|
|
Loading…
Reference in a new issue