build/xilinx: add support for edif/ngc files
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 16 Dec 2017 12:20:45 +0000 (13:20 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 16 Dec 2017 12:20:45 +0000 (13:20 +0100)
litex/build/xilinx/platform.py
litex/build/xilinx/vivado.py

index 04c8b4187d9231ea81fd8d9b79d065cb1ac4c8c9..64e9d97f221b172d82fb812a5eb5731213855b91 100644 (file)
@@ -1,3 +1,5 @@
+import os
+
 from litex.build.generic_platform import GenericPlatform
 from litex.build.xilinx import common, vivado, ise
 
@@ -7,6 +9,7 @@ class XilinxPlatform(GenericPlatform):
 
     def __init__(self, *args, toolchain="ise", **kwargs):
         GenericPlatform.__init__(self, *args, **kwargs)
+        self.edifs = set()
         if toolchain == "ise":
             self.toolchain = ise.XilinxISEToolchain()
         elif toolchain == "vivado":
@@ -14,6 +17,9 @@ class XilinxPlatform(GenericPlatform):
         else:
             raise ValueError("Unknown toolchain")
 
+    def add_edif(self, filename):
+        self.edifs.add((os.path.abspath(filename)))
+
     def get_verilog(self, *args, special_overrides=dict(), **kwargs):
         so = dict(common.xilinx_special_overrides)
         if self.device[:3] == "xc7":
index 8511a5c508932877f735f3224ff1a0373cba0420..b94b7b52af7e9c11398eb4eb8cec5246f8780f3b 100644 (file)
@@ -88,7 +88,7 @@ class XilinxVivadoToolchain:
         self.clocks = dict()
         self.false_paths = set()
 
-    def _build_batch(self, platform, sources, build_name):
+    def _build_batch(self, platform, sources, edifs, build_name):
         tcl = []
         tcl.append("create_property ars_ff cell")
         tcl.append("create_property ars_false_path net")
@@ -97,7 +97,9 @@ class XilinxVivadoToolchain:
             tcl.append("add_files " + filename_tcl)
             tcl.append("set_property library {} [get_files {}]"
                        .format(library, filename_tcl))
-
+        for filename in edifs:
+            filename_tcl = "{" + filename + "}"
+            tcl.append("read_edif " + filename_tcl)
         tcl.append("read_xdc {}.xdc".format(build_name))
         tcl.extend(c.format(build_name=build_name) for c in self.pre_synthesis_commands)
         # "-include_dirs {}" crashes Vivado 2016.4
@@ -191,7 +193,8 @@ class XilinxVivadoToolchain:
         v_file = build_name + ".v"
         v_output.write(v_file)
         sources = platform.sources | {(v_file, "verilog", "work")}
-        self._build_batch(platform, sources, build_name)
+        edifs = platform.edifs
+        self._build_batch(platform, sources, edifs, build_name)
         tools.write_to_file(build_name + ".xdc", _build_xdc(named_sc, named_pc))
         if run:
             _run_vivado(build_name, toolchain_path, source)