-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathroute.sh
executable file
·81 lines (68 loc) · 1.89 KB
/
route.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -e
# global variables
is_garnet=0
function print_usage() {
echo "Usage: $0 [--no-reg-fold] <arch_file> <netlist.packed>" >&2
exit 1
}
function detect_garnet() {
PATTERN="<CGRA>"
if grep -q "${PATTERN}" $1; then
is_garnet=0;
else
is_garnet=1;
fi
}
file_dir=$(dirname "$(realpath $0)")
root_dir=$(realpath $file_dir/../)
router=${root_dir}/cyclone/build/example/router
if [ "$#" -eq 2 ]; then
cgra=$1
packed=$2
elif [ "$#" -eq 3 ]; then
option=$1
cgra=$2
packed=$3
else
print_usage
fi
if ! [ -f ${cgra} ] || ! [ -f ${packed} ]; then
print_usage
fi
# assume user already have the env activated
place="${packed%.packed}.place"
if ! [ -f "$place" ] ; then
echo "$place not found" >&2
exit 1
fi
route="${packed%.packed}.route"
detect_garnet ${cgra}
# if it's garnet, we already have the grpah files specified
if [ ${is_garnet} -eq "1" ]; then
echo "Using routing files"
rm -rf ${route}
# garnet files has to use router
if ! [ -f ${router} ]; then
echo "${router} not found"
exit 1
fi
graphs=$(awk -F "=" '/graph/ {print $2}' ${cgra})
${router} ${packed} ${place} ${graphs[@]} ${route}
echo "Save result to ${route}"
else
# dump the graph files
graph_dir=$(dirname ${packed})
python ${root_dir}/process_graph.py -i ${cgra} -o ${graph_dir}
# if the C++ binary exists, we will use it instead
if [ -f ${router} ]; then
echo "Using C++ implementation"
rm -rf ${route}
${router} ${packed} ${place} 1 ${graph_dir}/1bit.graph \
16 ${graph_dir}/16bit.graph ${route}
else
echo "Using Python binding. Results may be undeterministic."
echo "To use C++ implementation, do ${root_dir}/cyclone/install.sh"
python ${root_dir}/router.py ${option} -g ${graph_dir} -i ${packed} -p ${place} -o ${route}
fi
fi