From 83fd066e598cb37ec19a8977ea0d4e209556c0f3 Mon Sep 17 00:00:00 2001
From: Dimitris Lampridis <Dimitris.Lampridis@cern.ch>
Date: Tue, 30 May 2017 15:23:44 +0200
Subject: [PATCH] syn: add post synthesis hook to generate the Xilinx PROM
 files

---
 hdl/syn/crio_wr_pmu/.gitignore  | 1 +
 hdl/syn/crio_wr_pmu/Manifest.py | 2 ++
 hdl/syn/crio_wr_pmu/prom_gen.sh | 9 +++++++++
 3 files changed, 12 insertions(+)
 create mode 100755 hdl/syn/crio_wr_pmu/prom_gen.sh

diff --git a/hdl/syn/crio_wr_pmu/.gitignore b/hdl/syn/crio_wr_pmu/.gitignore
index 436c0e7..3959bfe 100644
--- a/hdl/syn/crio_wr_pmu/.gitignore
+++ b/hdl/syn/crio_wr_pmu/.gitignore
@@ -2,3 +2,4 @@
 !.gitignore
 !Manifest.py
 !crio_wr_pmu.ucf
+!prom_gen.sh
diff --git a/hdl/syn/crio_wr_pmu/Manifest.py b/hdl/syn/crio_wr_pmu/Manifest.py
index 98c54f9..087eefb 100644
--- a/hdl/syn/crio_wr_pmu/Manifest.py
+++ b/hdl/syn/crio_wr_pmu/Manifest.py
@@ -10,6 +10,8 @@ syn_project = "crio_wr_pmu.xise"
 
 syn_tool = "ise"
 
+syn_post_cmd = "./prom_gen.sh"
+
 modules = {
     "local" : "../../top/crio_wr_pmu/",
 }
diff --git a/hdl/syn/crio_wr_pmu/prom_gen.sh b/hdl/syn/crio_wr_pmu/prom_gen.sh
new file mode 100755
index 0000000..a2b387b
--- /dev/null
+++ b/hdl/syn/crio_wr_pmu/prom_gen.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# convert .bit to .mcs, the result can be written to flash without erasing an existing SDBFS on it
+promgen -w -spi -p mcs -c FF -s 32768 -u 0 crio_wr_pmu_top.bit -o crio_wr_pmu.mcs
+
+# alternative .mcs with empty SDBFS appended. It should be used if there is no SDBFS on the flash
+wget http://www.ohwr.org/attachments/download/4558/sdbfs-standalone-160812.bin -O /tmp/sdbfs-standalone-160812.bin
+promgen -w -spi -p mcs -c FF -s 32768 -u 0 crio_wr_pmu_top.bit -bd /tmp/sdbfs-standalone-160812.bin start 0x170000 -o crio_wr_pmu_sdbfs.mcs
+rm /tmp/sdbfs-standalone-160812.bin
-- 
GitLab