Moved old bin2xdevcfg to revbin
[reconos.git] / tools / reconos_build_reconf.sh
blob20cbb24688454907aa32d154477c019da2a5ddfc
1 #!/bin/bash
3 # ____ _____
4 # ________ _________ ____ / __ \/ ___/
5 # / ___/ _ \/ ___/ __ \/ __ \/ / / /\__ \
6 # / / / __/ /__/ /_/ / / / / /_/ /___/ /
7 # /_/ \___/\___/\____/_/ /_/\____//____/
8 #
9 # ======================================================================
11 # project: ReconOS
12 # author: Christoph RĂ¼thing, University of Paderborn
13 # description: Build the current edk project with reconfigurable HWTs
14 # an generates the full and partial bitstreams.
16 # ======================================================================
18 set -e
20 xpartition()
22 config=$1
23 import=$2
24 include_idle=$3
26 xsts=`ls ../../../implementation/system_hwt_reconf_*.prj`
28 echo '<?xml version="1.0"?>' >> xpartition.pxml
29 echo '<Project Name="'$config'" FileVersion="1.2" ProjectVersion="2.0">' >> xpartition.pxml
30 if [ $import -ne 0 ]
31 then
32 echo ' <Partition Name="/system" State="import" ImportLocation="../idle">' >> xpartition.pxml
33 else
34 echo ' <Partition Name="/system" State="implement" ImportLocation="NONE">' >> xpartition.pxml
36 i=0
37 for xst in $xsts
39 idle=`grep "reconos_hwt_idle" $xst || true`
40 if [ -z "$idle" ]
41 then
42 echo ' <Partition Name="/system/hwt_reconf_'$i'" State="implement" ImportLocation="NONE" Reconfigurable="true" ReconfigModuleName="'$config'"></Partition>' >> xpartition.pxml
43 else
44 if [ $include_idle -eq 1 ]
45 then
46 echo ' <Partition Name="/system/hwt_reconf_'$i'" State="implement" ImportLocation="NONE" Reconfigurable="true" ReconfigModuleName="reconos_hwt_idle"></Partition>' >> xpartition.pxml
50 i=$(($i+1))
51 done
52 echo ' </Partition>' >> xpartition.pxml
53 echo '</Project>' >> xpartition.pxml
56 # figure out options
57 while getopts d opt
59 case $opt in
60 d) bitgenopt="-d";;
61 esac
62 done
65 if [ ! -f system.xmp ]
66 then
67 echo "ERROR: Call this script from a EDK projekt folder"
68 exit
71 device=`grep "Device: " system.xmp | tr -d ' '`
72 device=${device#*:}
74 package=`grep "Package: " system.xmp | tr -d ' '`
75 package=${package#*:}
77 speedgrade=`grep "SpeedGrade: " system.xmp | tr -d ' '`
78 speedgrade=${speedgrade#*:}
80 part=$device$package$speedgrade
82 mhss=`ls system_reconf_*.mhs`
85 # create working directory
87 if [ -d reconos_reconf ]
88 then
89 rm -rf reconos_reconf
92 mkdir -p reconos_reconf/syn/static
93 mkdir -p reconos_reconf/syn/idle
94 mkdir -p reconos_reconf/data
95 cp data/system.ucf reconos_reconf/data
98 # generate netlists and implement design
100 # run netlist for static design and copy netlists
101 rm -f system.mhs
102 ln -fs system_static.mhs system.mhs
104 echo -e "run hwclean\nrun netlist\nexit\n" | xps -nw system
106 # copy over generated netlists
107 cp implementation/system_hwt_reconf*.ngc reconos_reconf/syn/idle
108 cp implementation/*.ngc reconos_reconf/syn/static
109 rm -f reconos_reconf/syn/static/system_hwt_reconf*
111 mkdir -p reconos_reconf/imp/idle
112 cd reconos_reconf/imp/idle
115 # generate xpartiton.pxml for idle design
116 xpartition "idle" 0 1
118 # implement idle design
119 ngdbuild -sd ../../syn/static -sd ../../syn/idle -uc ../../data/system.ucf ../../syn/static/system.ngc system.ngd
120 map -w -detail -ol high -mt 4 -timing -o system_map.ncd system.ngd system.pcf
121 par -w -ol high -mt 4 system_map.ncd system.ncd system.pcf
122 bitgen system.ncd system.bit system.pcf -w -g ActiveReconfig:Yes -g Binary:Yes -g ConfigFallback:Disable $bitgenopt
124 cd ../../..
126 # generate reconfigurable configs
127 for mhs in $mhss
129 # determine config name
130 config=${mhs%_v?_??_?.*}
131 config=${config#system_reconf_}
133 # create syn and imp directory
134 mkdir -p reconos_reconf/syn/$config
135 mkdir -p reconos_reconf/imp/$config
137 # delete old hwt implementation
138 rm -rf implementation/system_hwt_reconf*
139 rm -rf implementation/cache/system_hwt_reconf*
141 rm -f system.mhs
142 ln -fs $mhs system.mhs
143 # run netlist
144 echo -e "run netlist\nexit\n" | xps -nw system
146 # copy netlists
147 cp implementation/system_hwt_reconf_*.ngc reconos_reconf/syn/$config
149 cd reconos_reconf/imp/$config
151 # generate xpartition.pxml
152 xpartition $config 1 0
154 ngdbuild -sd ../../syn/static -sd ../../syn/$config -uc ../../data/system.ucf ../../syn/static/system.ngc system.ngd
155 map -w -detail -ol high -mt 4 -o system_map.ncd system.ngd system.pcf
156 par -w -mt 4 system_map.ncd system.ncd system.pcf
157 bitgen system.ncd system.bit system.pcf -w -g ActiveReconfig:Yes -g Binary:Yes -g ConfigFallback:Disable $bitgenopt
159 cd ../../..
160 done
162 bins=`find reconos_reconf -iname *.bin -type f`
163 mkdir -p reconos_reconf/bin
165 for bin in $bins
167 name=`basename $bin`
168 reconos_revbin.sh $bin reconos_reconf/bin/$name
169 done