From c4b18090ace1acdb60e67bc600c7a70d454dc420 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <maltanar@gmail.com>
Date: Wed, 22 Jan 2020 23:18:00 +0000
Subject: [PATCH] [PYNQ] start adding SynthPYNQProject transform

---
 .../fpgadataflow/synth_pynq_proj.py           | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 src/finn/transformation/fpgadataflow/synth_pynq_proj.py

diff --git a/src/finn/transformation/fpgadataflow/synth_pynq_proj.py b/src/finn/transformation/fpgadataflow/synth_pynq_proj.py
new file mode 100644
index 000000000..7fafedb9c
--- /dev/null
+++ b/src/finn/transformation/fpgadataflow/synth_pynq_proj.py
@@ -0,0 +1,26 @@
+import os
+import subprocess
+
+from finn.transformation import Transformation
+
+
+class SynthPYNQProject(Transformation):
+    """Run synthesis for the PYNQ project for this graph. The MakePYNQProject
+    transformation must be applied prior to this transformation."""
+
+    def __init__(self):
+        super().__init__()
+
+    def apply(self, model):
+        vivado_pynq_proj_dir = model.get_metadata_prop("vivado_pynq_proj")
+        if vivado_pynq_proj_dir is None or (not os.path.isdir(vivado_pynq_proj_dir)):
+            raise Exception("No synthesis project, apply MakePYNQProject first.")
+        synth_project_sh = vivado_pynq_proj_dir + "/synth_project.sh"
+        if not os.path.isfile(synth_project_sh):
+            raise Exception("No synthesis script, apply MakePYNQProject first.")
+        bash_command = ["bash", synth_project_sh]
+        process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
+        process_compile.communicate()
+        # TODO set bitfile attribute
+        # TODO pull out synthesis statistics and put them in as attributes
+        return (model, False)
-- 
GitLab