From e233c62d276908c0aea8f6982711ee277c679ec4 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Tue, 25 Jun 2013 16:27:41 -0600 Subject: [PATCH] * generic_platform.py: add a finalize() method ... to add e.g. timing constraints after the other modules have had their say and when the signal names are known --- mibuild/altera_quartus.py | 1 + mibuild/generic_platform.py | 12 ++++++++++++ mibuild/xilinx_ise.py | 1 + 3 files changed, 14 insertions(+) diff --git a/mibuild/altera_quartus.py b/mibuild/altera_quartus.py index 4fc78550..dbb336a7 100644 --- a/mibuild/altera_quartus.py +++ b/mibuild/altera_quartus.py @@ -74,6 +74,7 @@ quartus_sta {build_name}.qpf class AlteraQuartusPlatform(GenericPlatform): def build(self, fragment, build_dir="build", build_name="top", quartus_path="/opt/Altera", run=True): + self.finalize(fragment) tools.mkdir_noerror(build_dir) os.chdir(build_dir) diff --git a/mibuild/generic_platform.py b/mibuild/generic_platform.py index 482c485e..2feb70e4 100644 --- a/mibuild/generic_platform.py +++ b/mibuild/generic_platform.py @@ -152,6 +152,7 @@ class GenericPlatform: name = self.__module__.split(".")[-1] self.name = name self.sources = [] + self.finalized = False def request(self, *args, **kwargs): return self.constraint_manager.request(*args, **kwargs) @@ -162,6 +163,17 @@ class GenericPlatform: def add_platform_command(self, *args, **kwargs): return self.constraint_manager.add_platform_command(*args, **kwargs) + def finalize(self, fragment, *args, **kwargs): + if self.finalized: + raise ConstraintError("Already finalized") + self.do_finalize(fragment, *args, **kwargs) + self.finalized = True + + def do_finalize(self, fragment, *args, **kwargs): + """overload this and e.g. add_platform_command()'s after the + modules had their say""" + pass + def add_source(self, filename, language=None): if language is None: language = tools.language_by_filename(filename) diff --git a/mibuild/xilinx_ise.py b/mibuild/xilinx_ise.py index bb70fdd3..2bc8c107 100644 --- a/mibuild/xilinx_ise.py +++ b/mibuild/xilinx_ise.py @@ -150,6 +150,7 @@ class XilinxISEPlatform(GenericPlatform): def build(self, fragment, build_dir="build", build_name="top", ise_path="/opt/Xilinx", source=True, run=True): + self.finalize(fragment) tools.mkdir_noerror(build_dir) os.chdir(build_dir) -- 2.30.2