-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·285 lines (249 loc) · 8.08 KB
/
configure
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/sh
#############################################################################
# This is a Matlab simulation configuration script file.
# The purpose is to control the toplevel simulation so that simulation
# and the result analysis can be controlled
# in parametrized manner from this single file
# Created by Marko Kosunen on 24.03.2015
# Last modification by Marko Kosunen, [email protected], 07.10.2020 16:01
#############################################################################
##Function to display help with -h argument and to control
##The configuration from the commnad line
help_f()
{
CAT << EOF
CONFIGURE Release 1.0 (04.04.2016)
configure-configuration script for a digital flow
Written by Marko Pikkis Kosunen
SYNOPSIS
configure [OPTIONS]
DESCRIPTION
Producess all configuration and Makefile for the visualization of
TheSyDeKick simulation
OPTIONS
-P
Do not reconfigure python control file.
-S
Do not reconfigure slides.
-h
Show this help.
EOF
}
# Configuration control, '1'=configure
#Only matlab or py, not both
PYCONF="1"
SLIDES="1"
while getopts CPSh opt
do
case "$opt" in
P) PYCONF="0";;
S) SLIDES="0";;
h) help_f; exit 0;;
\?) help_f;;
esac
done
#THE PARAMETERS
#These are the models you want to simulate with this file
# As per Release 1.4 this sim config with eldo and spectre chained does not work.
# Output of eldo/spectre is incompatible with the input of the inverter.
#PYTHONMODELS="[ 'py', 'sv', 'vhdl', 'eldo' ]"
PYTHONMODELS="[ 'py', 'sv', 'vhdl', 'spectre' ]"
######
# SET ALL VARIABLES AND PATHS RELATIVE TO THE CURRENT DESIGN
# Design paths
#Sets up THESDKHOME from gloabal setup file
. ../../TheSDK.config
# SET ALL VARIABLES AND PATHS RELATIVE TO THE CURRENT DESIGN
ROOTPATH=`pwd`
TEMPLATEDIR="${THESDKHOME}/Simulations/Slidetemplate"
PYTHONPATH="${ROOTPATH}/Python"
SLIDEPATH="${ROOTPATH}/Slides"
PICPATH="${ROOTPATH}/Pics"
#Check, create if missing
for dir in ${ROOTPATH} ${PYTHONPATH} ${PICPATH}; do
if [ ! -d "$dir" ]; then
echo "Creating directory $dir"
mkdir -p $dir
fi
done
if [ ! -d "$SLIDEPATH" ]; then
echo "Creating directory $dir"
${TEMPLATEDIR}/initslides ${SLIDEPATH}
fi
if [ ! -d "$SLIDEPATH/Pics" ]; then
echo "Creating directory $dir"
mkdir ${SLIDEPATH}/Pics
fi
#Top entity name and savestring (i.e. for filenames)
#Defaults the directory name
TOP_ENTITY=`basename $ROOTPATH`
PYFILE=`echo ${TOP_ENTITY} | sed 's/\([^[:alnum:]]*\)//g'`
if [ ${PYCONF} == "1" ]; then
#############################################################################
# Python command file generation
#############################################################################
CURRENTFILE="${PYTHONPATH}/${PYFILE}.py"
echo "Creating ${CURRENTFILE}"
cat <<EOF > ${CURRENTFILE}
#You may write any matlab code here to control your sim
import os
import sys
#These are here to keep the figures background in batch processing
import matplotlib
matplotlib.use('Agg')
rootpath='$ROOTPATH'
statusfile= rootpath + '/Python/' + os.path.splitext(os.path.basename(__file__))[0]+'.status'
picpath=rootpath + '/Pics';
import sys
sys.path.append ('${THESDKHOME}/Entities/thesdk')
from thesdk import *
from inv_sim import *
thesdk.initlog("${PYTHONPATH}/${PYFILE}.status")
t=inv_sim()
t.models=${PYTHONMODELS}
t.define_simple()
t.picpath=picpath;
t.run_simple()
t.plot()
EOF
fi
#############################################################################
# Slides generation
#############################################################################
if [ "${SLIDES}" == "1" ]; then
#############Slides latex file############################################
CURRENTFILE="${SLIDEPATH}/${TOP_ENTITY}.tex"
SLIDETITLE=`echo ${TOP_ENTITY} | sed 's/_/ /g'`
echo "Creating ${CURRENTFILE}"
#Generate preamble
cat <<EOF > ${CURRENTFILE}
\PassOptionsToPackage{ELEC}{aaltologo}
%\documentclass[first=dgreen,second=purple,logo=bluequo,normaltitle]{aaltoslides}
\documentclass[logo=bluequo]{aaltoslides}
%\documentclass{aaltoslides} % DEFAULT
%\documentclass[first=purple,second=lgreen,logo=bquo,normaltitle,nofoot]{aaltoslides} % SOME OPTION EXAMPLES
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{amssymb,amsmath}
\usepackage{url}
\usepackage{lastpage}
\usepackage{epstopdf}
%\usepackage[pdfpagemode=None,colorlinks=true,urlcolor=red, linkcolor=black,citecolor=black,pdfstartview=FitH]{hyperref}
\usepackage{mdframed}
\usepackage{caption}
\usepackage{apacite}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\tikzset{
every overlay node/.style={
%draw=black,fill=white,rounded corners,
anchor=north west, inner sep=0pt,
},
}
\def\tikzoverlay{%
\tikz[remember picture, overlay]\node[every overlay node]
}%
%%%% This for easy placemnet of figure inside a block
\newcommand{\putfig}[3][1.0]{
\begin{block}{#3}
\includegraphics[width=#1\linewidth,height=#1\textheight,keepaspectratio]{#2}
\end{block}
}
%%%%
%%%% To insert lecture date
\newcommand{\lectdate}{\today}
%%%%
\title{${SLIDETITLE}}
\author[Marko Kosunen]{Marko Kosunen}
\institute[MNT]{Department of Electronics and Nanoengineering\\\\
Aalto University, School of Electrical Engineering\\\\[email protected]}
\aaltofootertext{${SLIDETITLE}}{\lectdate}{\arabic{page}/\pageref{LastPage}\ }
\date{\lectdate}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generates the titleframe
\aaltotitleframe
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[t]
% \frametitle{${SLIDETITLE}}
% \begin{center}
% \includegraphics[width=0.5\linewidth]{./Pics/inv_sim_Rs_100000000_1.eps}
% \includegraphics[width=0.5\linewidth]{./Pics/inv_sim_Rs_100000000_2.eps}
% \end{center}
%\end{frame}
%\end{document}
EOF
#Calculate the number of models defined
echo $PYTHONMODELS
NMODS=`expr \`echo $PYTHONMODELS | wc -w\` - 2`
RANGE=$(($NMODS-1))
echo "Configuring slides for $NMODS models"
for FILE in `eval echo {0..$(($NMODS-1))}`; do
cat <<EOF >> ${CURRENTFILE}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{${SLIDETITLE} ${FILE}}
\begin{center}
\includegraphics[width=0.7\linewidth]{./Pics/inv_sim_Rs_100000000_${FILE}.eps}
\end{center}
\end{frame}
EOF
done
echo "\end{document}" >> ${CURRENTFILE}
fi
############################# MAKEFILE ####################################
CURRENTFILE="${ROOTPATH}/Makefile"
echo "Creating ${CURRENTFILE}"
cat <<EOF > ${CURRENTFILE}
CONTROLLER=${CONTROLLER}
#Directories
THESDKHOME = ${THESDKHOME}
TOP_ENTITY= ${TOP_ENTITY}
PYTHONPATH= ${PYTHONPATH}
PICPATH= ${PICPATH}
SLIDEPATH= ${SLIDEPATH}
PYFILE= ${PYFILE}
DEPDIR :=.depdir
\$(shell mkdir -p \$(DEPDIR) >/dev/null)
#Commands
PY= ${PY}
PYL= ${PYL}
PYI= ${PYI}
TOUCH=touch -r
#You must ensure these cmdfiles update the target
PYCMDFILE= \$(PYTHONPATH)/\$(PYFILE).py
PYTARGETS=\$(PYCMDFILE:.py=.status) #Ensure these files are generated with python cmd
ifeq (\$(CONTROLLER), PYTHON)
.PHONY: py pyl slides all
all: python slides
endif
slides: \$(SLIDEPATH)/pdffiles/\$(TOP_ENTITY).pdf
ifeq (\$(CONTROLLER), PYTHON)
\$(SLIDEPATH)/pdffiles/%.pdf : \$(PYTHONPATH)/\$(PYFILE).status
ln -sf \$(PICPATH)/*.eps \$(SLIDEPATH)/Pics/
cd \$(SLIDEPATH) && ./makearticle \$(SLIDEPATH)/\$(*F).tex && cd ..
endif
#Python submission
python: \$(PYTARGETS)
\$(PYTHONPATH)/%.status : \$(PYTHONPATH)/%.py
\$(PYI) \$(PYTHONPATH)/\$(PYFILE).py
@grep -i WARNING \$@ | uniq | sed -n 's/\(^.*\)\(WARNING.*\\$\)/\2/p'
py:
\$(PYI) \$(PYTHONPATH)/\$(PYFILE).py
#local Python submission
pyl:
\$(PYL) \$(PYTHONPATH)/\$(PYFILE).py
clean:
rm -f \$(PYTHONPATH)/*.status
rm -f \$(SLIDEPATH)/Pics/*.eps
rm -f \$(PICPATH)/*.eps
rm -f \$(SLIDEPATH)/Pdffiles/*.pdf
rm -rf \$(DEPDIR)
EOF
#Note because of broken dependencytracking for Python
echo "NOTE:Controller is ${CONTROLLER}"
if [ "${CONTROLLER}" == "PYTHON" ]; then
echo "Dependency tracking for \"make all\" is NOT functional"
fi
##################Hereafter some files you should not need to modify ################################