From 4c82eb549f1f635cd12a130f40c1a7b700cf766c Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sat, 16 Dec 2017 13:20:45 +0100 Subject: [PATCH] build/xilinx: add support for edif/ngc files --- litex/build/xilinx/platform.py | 6 ++++++ litex/build/xilinx/vivado.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/litex/build/xilinx/platform.py b/litex/build/xilinx/platform.py index 04c8b4187..64e9d97f2 100644 --- a/litex/build/xilinx/platform.py +++ b/litex/build/xilinx/platform.py @@ -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": diff --git a/litex/build/xilinx/vivado.py b/litex/build/xilinx/vivado.py index 8511a5c50..b94b7b52a 100644 --- a/litex/build/xilinx/vivado.py +++ b/litex/build/xilinx/vivado.py @@ -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)