| 1 |
\documentclass{article} |
| 2 |
|
| 3 |
\usepackage{timing-diagrams} |
| 4 |
|
| 5 |
\usepackage{pifont} |
| 6 |
|
| 7 |
\begin{document} |
| 8 |
|
| 9 |
\section{Basic diagram} |
| 10 |
|
| 11 |
\begin{tikzpicture} |
| 12 |
% Define timelines with their names, and ordinate as #2: |
| 13 |
\tline{A}{2}; |
| 14 |
\tline{B}{0}; |
| 15 |
% Actually draw the timelines (#2 is the horizontal length): |
| 16 |
\ttimeline{A}{5}; |
| 17 |
\ttimeline{B}{5}; |
| 18 |
% Provide captions for timelines: |
| 19 |
\tcaption{A}{A's caption}; |
| 20 |
\tcaption{B}{B's caption}; |
| 21 |
|
| 22 |
% Draw the actual content: |
| 23 |
% tick = vertical line accros the timeline |
| 24 |
\ttick{A}; |
| 25 |
% advance time |
| 26 |
\tskip{A}{2}; |
| 27 |
% This one will be drawn 2 time units after the previous, because of |
| 28 |
% the \tskip: |
| 29 |
\ttick{A}; |
| 30 |
|
| 31 |
% One more with the same principle: |
| 32 |
\tskip{A}{1}; |
| 33 |
\ttick{A}; |
| 34 |
|
| 35 |
% Same as above, but on timeline B: |
| 36 |
\ttick{B}; |
| 37 |
\tskip{B}{1}; |
| 38 |
% \tbox creates a box with non-null width, and text inside: |
| 39 |
\tbox{B}{3}{Box on B}; |
| 40 |
\end{tikzpicture} |
| 41 |
|
| 42 |
\section{Timeline, ticks and tasks} |
| 43 |
|
| 44 |
\begin{tikzpicture} |
| 45 |
\draw (-1,1.5) node[rotate=90] (systemc) {\textsf{\large SystemC}}; |
| 46 |
\draw[dashed] (-1,0) -- (9,0); |
| 47 |
\draw (-1,-2) node[rotate=90] (jtlm) {\textsf{\large jTLM}}; |
| 48 |
|
| 49 |
% SystemC |
| 50 |
\tline{A}{2.1}; |
| 51 |
\tcaption{A}{A}; |
| 52 |
\tline{B}{1}; |
| 53 |
\tcaption{B}{B}; |
| 54 |
|
| 55 |
\ttimeline{A}{5}; |
| 56 |
\ttimeline{B}{5}; |
| 57 |
|
| 58 |
% jTLM |
| 59 |
\tline{P}{-1.5}; |
| 60 |
\tcaption{P}{P}; |
| 61 |
\tline{Q}{-2.6}; |
| 62 |
\tcaption{Q}{Q}; |
| 63 |
|
| 64 |
\ttimeline{P}{5}; |
| 65 |
\ttimeline{Q}{5}; |
| 66 |
|
| 67 |
|
| 68 |
\ttick{A}; |
| 69 |
\ttextU{A}{f()}; |
| 70 |
\tskiptext{A}{2}{\texttt{wait(20)}}; |
| 71 |
\ttick{A}; |
| 72 |
\tskip{A}{1}; |
| 73 |
\ttick{A}; |
| 74 |
|
| 75 |
\ttick{B} |
| 76 |
\tskip{B}{1}; |
| 77 |
\ttick{B}; |
| 78 |
\tskip{B}{1}; |
| 79 |
\ttick{B}; |
| 80 |
\tskip{B}{2}; |
| 81 |
\ttick{B}; |
| 82 |
|
| 83 |
\ttick{P} |
| 84 |
\ttextU{P}{g()}; |
| 85 |
\tskiptext{P}{2}{awaitTime} |
| 86 |
\ttick{P}; |
| 87 |
|
| 88 |
\tbox{P}{1.5}{h()}; |
| 89 |
|
| 90 |
% just so that the final picture looks pretty |
| 91 |
\tbox{Q}{1.3}{i()}; |
| 92 |
\tskip{Q}{1}; |
| 93 |
\ttick{Q}; |
| 94 |
\tskip{Q}{.5}; |
| 95 |
\tbox{Q}{2}{j()}; |
| 96 |
|
| 97 |
\end{tikzpicture} |
| 98 |
|
| 99 |
\section{Annotations over a diagram} |
| 100 |
|
| 101 |
\begin{tikzpicture} |
| 102 |
\tline{real}{0}; |
| 103 |
\tline{model}{2}; |
| 104 |
|
| 105 |
\ttimeline{real}{8.5}; |
| 106 |
\ttimeline{model}{8.5}; |
| 107 |
|
| 108 |
\tcaption{real}{Real system}; |
| 109 |
\tcaption{model}{SystemC model}; |
| 110 |
|
| 111 |
\tskip{real}{.5}; |
| 112 |
\tskip{model}{.5}; |
| 113 |
|
| 114 |
\path (currentrealU) coordinate (endzooma); |
| 115 |
\tbox{real}{7}{\texttt{compute()}}; |
| 116 |
\path (currentrealU) ++(-.04, 0) coordinate (endzoomb); |
| 117 |
\tstrongtick{real}; |
| 118 |
\ttextarrowU{real}{\texttt{commit()}}; |
| 119 |
|
| 120 |
\tstrongtick{model}; |
| 121 |
\path (currentmodelL) ++(-.04, 0) coordinate(startzooma); |
| 122 |
\path (currentmodelL) ++( .04, 0) coordinate(startzoomb); |
| 123 |
\ttextarrowU{model}{\texttt{compute()}}; |
| 124 |
\tskip{model}{.04}; |
| 125 |
\tskiptext{model}{6.92}{\texttt{wait()}}; |
| 126 |
\tskip{model}{.04}; |
| 127 |
\tstrongtick{model}; |
| 128 |
\ttextarrowU{model}{\texttt{commit()}}; |
| 129 |
|
| 130 |
\path (startzoomb -| endzoomb) coordinate (topright); |
| 131 |
\path (barycentric cs:startzoomb=.5,endzooma=.5) coordinate (tmpa); |
| 132 |
\path (barycentric cs:topright=.5,endzoomb=.5) coordinate (tmpb); |
| 133 |
\draw[very thin,color=black!70!white] (startzooma) -- (endzooma); |
| 134 |
\draw[very thin,color=black!70!white] (startzoomb) .. controls (tmpa) and (tmpb) .. (endzoomb); |
| 135 |
\end{tikzpicture} |
| 136 |
|
| 137 |
\section{Annotations with callouts, synchronizations between timelines} |
| 138 |
|
| 139 |
\newcommand{\one}{\raisebox{-2pt}{\large\ding{192}}} |
| 140 |
\newcommand{\two}{\raisebox{-1.5pt}{\large\ding{193}}} |
| 141 |
\newcommand{\three}{\raisebox{-2pt}{\large\ding{194}}} |
| 142 |
\tikzstyle{arrow}=[->,line width=.05cm,draw=red!90!blue!60!black] |
| 143 |
|
| 144 |
\begin{tikzpicture}[scale=.8] |
| 145 |
\tline{A}{3}; |
| 146 |
\tcaption{A}{A}; |
| 147 |
\tline{B}{2}; |
| 148 |
\tcaption{B}{B}; |
| 149 |
\tline{C}{1}; |
| 150 |
\tcaption{C}{C}; |
| 151 |
\tline{T}{-1.5} |
| 152 |
\tcaption{T}{OS thread}; |
| 153 |
|
| 154 |
\ttimeline{A}{10}; |
| 155 |
\ttimeline{B}{10}; |
| 156 |
\ttimeline{C}{10}; |
| 157 |
\ttimeline{T}{10}; |
| 158 |
|
| 159 |
\tbox{B}{1}{}; |
| 160 |
\tcatchup{C}{B}; |
| 161 |
% |
| 162 |
\tbox{C}{1}{}; |
| 163 |
\tcalloutU[(-.8,2.5)]{C}{\texttt{during(42, routine);}} |
| 164 |
% |
| 165 |
% |
| 166 |
\tcatchup{B}{C}; |
| 167 |
\tcatchup{T}{C}; |
| 168 |
\draw[arrow] (currentCL) -- node[left] { |
| 169 |
\begin{tabular}{r} |
| 170 |
\one{} create\\thread |
| 171 |
\end{tabular} |
| 172 |
} (currentTU); |
| 173 |
\tbox{T}{4}{\texttt{routine}}; |
| 174 |
% |
| 175 |
% |
| 176 |
\tskiptextL{C}{4}{\two{} \texttt{wait(42)}\vspace{-2em}}; |
| 177 |
% |
| 178 |
% |
| 179 |
\tbox{B}{1.5}{}; |
| 180 |
\tcatchup{A}{B}; |
| 181 |
\tbox{A}{1}{}; |
| 182 |
\tcatchup{B}{A}; |
| 183 |
\tbox{B}{1}{}; |
| 184 |
% |
| 185 |
% |
| 186 |
\draw[arrow] (currentTU) -- node[right] { |
| 187 |
\begin{tabular}{l} |
| 188 |
\three{} join\\thread |
| 189 |
\end{tabular} |
| 190 |
} (currentCL); |
| 191 |
\tbox{C}{1}{}; |
| 192 |
% |
| 193 |
% |
| 194 |
\tcatchup{A}{C}; |
| 195 |
\tbox{A}{1}{}; |
| 196 |
\tcatchup{B}{A}; |
| 197 |
\tbox{B}{1}{}; |
| 198 |
% |
| 199 |
\end{tikzpicture} |
| 200 |
|
| 201 |
\section{Arrows between timelines} |
| 202 |
|
| 203 |
|
| 204 |
\begin{tikzpicture}[scale=.7] |
| 205 |
\tline{sc}{2}; |
| 206 |
\tcaption{sc}{SystemC}; |
| 207 |
|
| 208 |
\tline{ace}{0}; |
| 209 |
\draw (currentace) ++ (9,-.3) node {Simulated time}; |
| 210 |
|
| 211 |
\tcaption{ace}{P/T Solver}; |
| 212 |
|
| 213 |
\ttimeline{sc}{10}; |
| 214 |
\ttimeline{ace}{10}; |
| 215 |
|
| 216 |
\tremember{sc}{before}; |
| 217 |
\tlonglighttick{sc}; |
| 218 |
\tskip{sc}{1.5}; |
| 219 |
\tlonglighttick{sc}; |
| 220 |
\tskip{sc}{1.5}; |
| 221 |
\tlonglighttick{sc}; |
| 222 |
\tskip{sc}{2}; |
| 223 |
\trecall{sc}{before}; |
| 224 |
\tbox{sc}{6}{Functional (1)}; |
| 225 |
|
| 226 |
\ttextarrowU{sc}{\begin{tabular}{c} |
| 227 |
SystemC reads\\temperature |
| 228 |
\end{tabular} |
| 229 |
}; |
| 230 |
|
| 231 |
\tarrowUL{sc}{ace}{}; |
| 232 |
\draw (tmpmid) node[fill=white,inner sep=1pt] {(2)}; |
| 233 |
\tremember{ace}{before}; |
| 234 |
\tlonglighttick{ace}; |
| 235 |
\tskip{ace}{1.5}; |
| 236 |
\tlonglighttick{ace}; |
| 237 |
\tskip{ace}{1.5}; |
| 238 |
\tlonglighttick{ace}; |
| 239 |
\tskip{ace}{2}; |
| 240 |
\trecall{ace}{before}; |
| 241 |
\tbox{ace}{6}{Non-functional (3)}; |
| 242 |
|
| 243 |
\tarrowLU{ace}{sc}{}; |
| 244 |
\draw (tmpmid) node[anchor=west] {(4)}; |
| 245 |
|
| 246 |
\tbox{sc}{2}{...}; |
| 247 |
\end{tikzpicture} |
| 248 |
|
| 249 |
\vspace{1em} |
| 250 |
|
| 251 |
\begin{tikzpicture}[scale=.7] |
| 252 |
\tline{sc}{2}; |
| 253 |
\tcaption{sc}{SystemC}; |
| 254 |
|
| 255 |
\tline{ace}{0}; |
| 256 |
\tcaption{ace}{P/T Solver}; |
| 257 |
|
| 258 |
\draw (currentace) ++ (9,-.3) node {Simulated time}; |
| 259 |
|
| 260 |
\ttimeline{sc}{10}; |
| 261 |
\ttimeline{ace}{10}; |
| 262 |
|
| 263 |
\tbox{sc}{1}{(1)}; |
| 264 |
\ttextarrowU{sc}{end of instant $t_{i}$}; |
| 265 |
\tcatchup{ace}{sc}; |
| 266 |
\coordinate (sceoi) at (currentscL); |
| 267 |
|
| 268 |
\tskip{sc}{6}; |
| 269 |
\ttick{sc}; |
| 270 |
\ttextarrowU{sc}{next instant $t_{i+1}$}; |
| 271 |
|
| 272 |
\tarrowCoord{(sceoi)}{(currentaceU)}{}; |
| 273 |
\draw (tmpmid) node[anchor=east] {(2)}; |
| 274 |
\tbox{ace}{6}{non-functional simu (3)}; |
| 275 |
% \tcalloutL{ace}{No IT}; |
| 276 |
\ttick{sc}; |
| 277 |
\tarrowLU{ace}{sc}{}; |
| 278 |
\draw (tmpmid) node[anchor=west] {(4)}; |
| 279 |
% \tcalloutU{sc}{Continue}; |
| 280 |
\tbox{sc}{1}{...}; |
| 281 |
|
| 282 |
\end{tikzpicture} |
| 283 |
|
| 284 |
\section{Events as vertical arrows, mix between timing diagrams and others} |
| 285 |
|
| 286 |
\begin{tikzpicture} |
| 287 |
\tline{S}{6}; |
| 288 |
\tline{M}{5}; |
| 289 |
\tline{E}{2}; |
| 290 |
\tline{T}{0} |
| 291 |
\tline{F}{-2}; |
| 292 |
\tline{Eb}{-5}; |
| 293 |
\tline{Tb}{-7} |
| 294 |
|
| 295 |
\coordinate (n1) at (-2.5,-.5); |
| 296 |
\coordinate (n2) at (-2.5,4); |
| 297 |
\draw [decoration={brace,amplitude=10pt},decorate] (n1) to (n2); |
| 298 |
|
| 299 |
\coordinate (o1) at (-2.5,-7.5); |
| 300 |
\coordinate (o2) at (-2.5,-1.5); |
| 301 |
\draw [decoration={brace,amplitude=10pt},decorate] (o1) to (o2); |
| 302 |
|
| 303 |
\draw (barycentric cs:n1=.5,n2=.5) ++(-10pt,0) node[anchor=south,rotate=90] {\large\textsf{(a) Naive Temperature Model}}; |
| 304 |
\draw (barycentric cs:o1=.5,o2=.5) ++(-10pt,0) node[anchor=south,rotate=90] {\large\textsf{(b) Proposed Approach}}; |
| 305 |
|
| 306 |
\tcaption{S}{Real System}; |
| 307 |
\ttimeline{S}{8}; |
| 308 |
|
| 309 |
\tskip{S}{.3}; |
| 310 |
|
| 311 |
\tstartbrace{S}; |
| 312 |
\tevent{S}; \tskip{S}{1.5}; |
| 313 |
\tevent{S}; \tskip{S}{1.3}; |
| 314 |
\tevent{S}; \tskip{S}{1.2}; |
| 315 |
|
| 316 |
\tendbrace{S}{\texttt{f(); wait(40);}}; |
| 317 |
\tstartbrace{S}; |
| 318 |
|
| 319 |
\tskip{S}{.2}; |
| 320 |
\tevent{S}; \tskip{S}{.8}; |
| 321 |
\tevent{S}; \tskip{S}{.7}; |
| 322 |
\tevent{S}; \tskip{S}{.5}; |
| 323 |
\tevent{S}; \tskip{S}{.5}; |
| 324 |
\tevent{S}; \tskip{S}{.8}; |
| 325 |
\tevent{S}; |
| 326 |
|
| 327 |
\tendbrace{S}{\texttt{g(); wait(35);}}; |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
\tcaption{M}{ |
| 332 |
\begin{tabular}{r} |
| 333 |
Loosely-Timed\\Model |
| 334 |
\end{tabular} |
| 335 |
}; |
| 336 |
\ttimeline{M}{8}; |
| 337 |
\tskip{M}{.3}; |
| 338 |
\foreach \x in {10,0,-10} { |
| 339 |
\teventA{M}{\x}; |
| 340 |
} |
| 341 |
\tskip{M}{4}; |
| 342 |
\foreach \x in {25,15,5,-5,-15,-25} { |
| 343 |
\teventA{M}{\x}; |
| 344 |
} |
| 345 |
\tskip{M}{2.5}; |
| 346 |
|
| 347 |
|
| 348 |
\tcaption{E}{Energy}; |
| 349 |
\ttimeline{E}{8}; |
| 350 |
|
| 351 |
\draw[red!50!black,thick] (currentE) ++(0,.3) -- ++(.3,0) -- |
| 352 |
node[right] {+3} ++(0,.6) -- ++(4,0) -- |
| 353 |
node[right] {+6} ++(0,1.2) -- node[near end,below]{total=9} ++(3.5,0) |
| 354 |
; |
| 355 |
|
| 356 |
|
| 357 |
\tcaption{T}{Temperature}; |
| 358 |
|
| 359 |
\ttimeline{T}{8}; |
| 360 |
\draw[blue!50!black,thick] (currentT) ++(0,.3) -- ++(.3,0) -- |
| 361 |
coordinate[at end](peak1) ++(0,.6) .. controls +(1,-.2) .. ++(4,-.3) -- |
| 362 |
coordinate[at end](peak2) ++(0,1) .. controls +(1,-.5) .. ++(3.5,-.8) |
| 363 |
; |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
\draw (peak1) node[draw,circle,thick](peak1){}; |
| 368 |
\draw (peak2) node[draw,circle,thick](peak2){}; |
| 369 |
\draw (barycentric cs:peak1=.5,peak2=.5) ++(0,.1) node[inner sep=0](peaks){ |
| 370 |
\begin{tabular}{c} |
| 371 |
Unrealistic\\peaks |
| 372 |
\end{tabular} |
| 373 |
}; |
| 374 |
\draw [arrow] (peaks) -- (peak1); |
| 375 |
\draw [arrow] (peaks) -- (peak2); |
| 376 |
|
| 377 |
|
| 378 |
\tcaption{F}{Frequency}; |
| 379 |
\ttimeline{F}{8}; |
| 380 |
\tskip{F}{.3}; |
| 381 |
\tbox{F}{4}{$\frac{3}{40}$ trans/sec}; |
| 382 |
\tbox{F}{3.5}{$\frac{6}{35}$ trans/sec}; |
| 383 |
|
| 384 |
|
| 385 |
\tcaption{Eb}{Energy}; |
| 386 |
\ttimeline{Eb}{8}; |
| 387 |
|
| 388 |
\draw[red!50!black,thick] (currentEb) ++(0,.3) -- ++(.3,0) -- |
| 389 |
++(4,.6) |
| 390 |
-- node[at end,right]{total=9} ++(3.5,1.2) |
| 391 |
; |
| 392 |
|
| 393 |
|
| 394 |
\tcaption{Tb}{Temperature}; |
| 395 |
|
| 396 |
\ttimeline{Tb}{8}; |
| 397 |
\draw[blue!50!black,thick] (currentTb) ++(0,.3) -- coordinate[at end](start)++(.3,0); |
| 398 |
\path (start) |
| 399 |
++(4,.6) coordinate (x1) |
| 400 |
++(3.5,.3) coordinate(x2); |
| 401 |
\draw[blue!50!black,thick,bend left=5] (start) to (x1); |
| 402 |
\draw[blue!50!black,thick,bend left=5] (x1) to (x2); |
| 403 |
; |
| 404 |
|
| 405 |
\end{tikzpicture} |
| 406 |
|
| 407 |
\end{document} |
| 408 |
|
| 409 |
%%% Local Variables: |
| 410 |
%%% mode: latex |
| 411 |
%%% TeX-master: t |
| 412 |
%%% End: |