* generic_platform.py: add a finalize() method
authorRobert Jordens <jordens@gmail.com>
Tue, 25 Jun 2013 22:27:41 +0000 (16:27 -0600)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 27 Jun 2013 17:17:02 +0000 (19:17 +0200)
... 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
mibuild/generic_platform.py
mibuild/xilinx_ise.py

index 4fc7855092ffe7636d7156e9529c22ecf8d191e4..dbb336a75ad698cc4cb498b7f1392512f8a2dc9e 100644 (file)
@@ -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)
 
index 482c485e84f9c948d01c6301031e301d1ad89346..2feb70e4d80c6d06b46f97da739d558ee5a5e7dc 100644 (file)
@@ -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)
index bb70fdd3c2dd40f4f87ae30e36f829c09fdcb250..2bc8c107f56d3066ebefe794253a327217646e02 100644 (file)
@@ -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)