File size: 4,282 Bytes
5cdf637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash

if [[ $# != 10 ]]; then
        echo "you need to give X arguments:"   
        echo "  1st - the ioPlacer binary path"
	echo "  2nd - ioPlacer arguments" 
        echo "  3rd - the RePlAce binary path"
	echo "  4th - RePlAce arguments"
        echo "  5th - the number of iterations"
        echo "  6th - a LEF file path"
        echo "  7th - a DEF file path"
        echo "  8th - output directory, where the logs and the final DEF will be saved"
        echo "	9th - DEF file name (without .def extension)"
	echo "	10th - Boolean to indicate if DEF has pin placement"
	exit 1
fi

ioplacerArgs="$2"
replaceArgs="$4"
iterations="$5"
ioBin="$1"
replaceBin="$3"
lefFile="$6"
defFile="$7"
outputdir="$8"
defName="$9"
hasIoPlace="${10}"

# Directory used to save the parcial DEFs of each iteration
runDir="runLoop"
replaceOutDir="${outputdir}/replace"
ioplaceOutDir="${outputdir}/ioplace"

mkdir -p $replaceOutDir
mkdir -p $ioplaceOutDir
mkdir -p $runDir

if [[ ! -f "${ioBin}" ]]; then
        echo "IOPlacement binary not found, you need to compile it before"
        exit 1
fi

if [[ ! -f "${replaceBin}" ]]; then
        echo "RePlAce binary not found, you need to compile it before"
        exit 1
fi

if [[ ! -f "${lefFile}" ]]; then
        echo "LEF file not found"
        exit 1
fi

if [[ ! -f "${defFile}" ]]; then
        echo "DEF file not found"
        exit 1
fi

cp ${defFile} ${runDir}/${defName}.def

if [[ "${hasIoPlace}" == 0  ]]
then
	"$ioBin" \
                -l ${lefFile} \
                -d ${defFile} \
                ${ioplacerArgs} \
                -o out.def

        mv out.def ${runDir}/${defName}.def
fi

# Main loop
replaceExperimentDir="${replaceOutDir}/etc/${defName}/experiment"
# do n iterations (user input)
for j in $(seq 0 "${iterations}")
do
        echo "----Iteration $j"
        logsFolder="${ioplaceOutDir}/it${j}/${defName}/logs"
        mkdir -p "$logsFolder"
        replaceExperimentDEF=${j}/${defName}_final.def

        echo "--------Running RePlAce"
        # Run RePlAce to generate a placed DEF
              
        #first iteration uses '-fast' flag for RePlAce and the input DEF
        if [[ "${j}" == 0 ]] 
        then
                echo "------------Creating initial def with '-fast' flag"
                if [[ "${hasIoPlace}" == 0  ]]
		then
			${replaceBin} \
				-bmflag etc \
				-lef ${lefFile} \
				-def ${runDir}/${defName}.def \
				${replaceArgs} \
				-output ${replaceOutDir} \
                        	-fast \
                        	> "$logsFolder"/replace_test"${i}"_it"${j}".log
		else
			${replaceBin} \
                                -bmflag etc \
                                -lef ${lefFile} \
                                -def ${defFile} \
                                ${replaceArgs} \
                                -output ${replaceOutDir} \
                                -fast \
                                > "$logsFolder"/replace_test"${i}"_it"${j}".log
		fi
        else 
                ${replaceBin} \
			-bmflag etc \
			-lef ${lefFile} \
			-def ${runDir}/${defName}.def \
			${replaceArgs} \
			-output ${replaceOutDir} \
                        > "$logsFolder"/replace_test"${i}"_it"${j}".log
        fi

        if [ "${j}" -lt 10 ]; then
                cp "${replaceExperimentDir}00${replaceExperimentDEF}" \
                        ${runDir}/${curr_test}.replace.def
        elif [ "${j}" -lt 100 ]; then
                cp "${replaceExperimentDir}0${replaceExperimentDEF}" \
                        ${runDir}/${curr_test}.replace.def
        else
                cp "${replaceExperimentDir}${replaceExperimentDEF}" \
                        ${runDir}/${curr_test}.replace.def
        fi

        echo "--------Running ioPlacer"
        # Run ioPlacer to place the IO pins for the placed DEF
        ioLogFile="${logsFolder}/ioPlacer_test${i}_it${j}.log"
              
        "$ioBin" \
                -l ${lefFile} \
                -d ${runDir}/${curr_test}.replace.def \
                ${ioplacerArgs} \
		-o out.def > "$ioLogFile"
        
	mv out.def ${runDir}/${defName}.def
done

finalDEFs="finalDEFs"
mkdir -p ${outputdir}/${finalDEFs}
mv ${runDir}/${defName}.def ${outputdir}/${finalDEFs}/${defName}.final.def
rm -Rf ${runDir}