From 4dbb5352ad52518d74b81289868ab616a07bc6ff Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 3 Aug 2019 16:18:46 +0000 Subject: [PATCH] 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. --- nmigen/build/plat.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/nmigen/build/plat.py b/nmigen/build/plat.py index f4c5cd5..ef39d23 100644 --- a/nmigen/build/plat.py +++ b/nmigen/build/plat.py @@ -18,8 +18,9 @@ __all__ = ["Platform", "TemplatedPlatform"] class Platform(ResourceManager, metaclass=ABCMeta): - resources = abstractproperty() - connectors = abstractproperty() + 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") -- 2.30.2