summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/timing-diagrams/diagrams-examples.tex
blob: c7b1240a1d2c82324169f47daf08f41a462219cd (plain)
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
\documentclass{article}

\usepackage{timing-diagrams}

\usepackage{pifont}

\begin{document}

\section{Basic diagram}

\begin{tikzpicture}
  % Define timelines with their names, and ordinate as #2:
  \tline{A}{2};
  \tline{B}{0};
  % Actually draw the timelines (#2 is the horizontal length):
  \ttimeline{A}{5};
  \ttimeline{B}{5};
  % Provide captions for timelines:
  \tcaption{A}{A's caption};
  \tcaption{B}{B's caption};
  
  % Draw the actual content:
  % tick = vertical line accros the timeline
  \ttick{A};
  % advance time
  \tskip{A}{2};
  % This one will be drawn 2 time units after the previous, because of
  % the \tskip:
  \ttick{A};
  
  % One more with the same principle:
  \tskip{A}{1};
  \ttick{A};

  % Same as above, but on timeline B:
  \ttick{B};
  \tskip{B}{1};
  % \tbox creates a box with non-null width, and text inside:
  \tbox{B}{3}{Box on B};
\end{tikzpicture}

\section{Timeline, ticks and tasks}

\begin{tikzpicture}
  \draw (-1,1.5)  node[rotate=90] (systemc) {\textsf{\large SystemC}};
  \draw[dashed] (-1,0) -- (9,0);
  \draw (-1,-2) node[rotate=90] (jtlm) {\textsf{\large jTLM}};

  % SystemC
  \tline{A}{2.1};
  \tcaption{A}{A};
  \tline{B}{1};
  \tcaption{B}{B};

  \ttimeline{A}{5};
  \ttimeline{B}{5};

  % jTLM
  \tline{P}{-1.5};
  \tcaption{P}{P};
  \tline{Q}{-2.6};
  \tcaption{Q}{Q};

  \ttimeline{P}{5};
  \ttimeline{Q}{5};


  \ttick{A};
  \ttextU{A}{f()};
  \tskiptext{A}{2}{\texttt{wait(20)}};
  \ttick{A};
  \tskip{A}{1};
  \ttick{A};

  \ttick{B}
  \tskip{B}{1};
  \ttick{B};
  \tskip{B}{1};
  \ttick{B};
  \tskip{B}{2};
  \ttick{B};

  \ttick{P}
  \ttextU{P}{g()};
  \tskiptext{P}{2}{awaitTime}
  \ttick{P};

  \tbox{P}{1.5}{h()};

  % just so that the final picture looks pretty
  \tbox{Q}{1.3}{i()};
  \tskip{Q}{1};
  \ttick{Q};
  \tskip{Q}{.5};
  \tbox{Q}{2}{j()};

\end{tikzpicture}

\section{Annotations over a diagram}

\begin{tikzpicture}
  \tline{real}{0};
  \tline{model}{2};

  \ttimeline{real}{8.5};
  \ttimeline{model}{8.5};

  \tcaption{real}{Real system};
  \tcaption{model}{SystemC model};

  \tskip{real}{.5};
  \tskip{model}{.5};

  \path (currentrealU) coordinate (endzooma);
  \tbox{real}{7}{\texttt{compute()}};
  \path (currentrealU) ++(-.04, 0) coordinate (endzoomb);
  \tstrongtick{real};
  \ttextarrowU{real}{\texttt{commit()}};

  \tstrongtick{model};
  \path (currentmodelL) ++(-.04, 0) coordinate(startzooma);
  \path (currentmodelL) ++( .04, 0) coordinate(startzoomb);
  \ttextarrowU{model}{\texttt{compute()}};
  \tskip{model}{.04};
  \tskiptext{model}{6.92}{\texttt{wait()}};
  \tskip{model}{.04};
  \tstrongtick{model};
  \ttextarrowU{model}{\texttt{commit()}};

  \path (startzoomb -| endzoomb) coordinate (topright);
  \path (barycentric cs:startzoomb=.5,endzooma=.5) coordinate (tmpa);
  \path (barycentric cs:topright=.5,endzoomb=.5) coordinate (tmpb);
  \draw[very thin,color=black!70!white] (startzooma) -- (endzooma);
  \draw[very thin,color=black!70!white] (startzoomb) .. controls (tmpa) and (tmpb) .. (endzoomb);
\end{tikzpicture}

\section{Annotations with callouts, synchronizations between timelines}

\newcommand{\one}{\raisebox{-2pt}{\large\ding{192}}}
\newcommand{\two}{\raisebox{-1.5pt}{\large\ding{193}}}
\newcommand{\three}{\raisebox{-2pt}{\large\ding{194}}}
\tikzstyle{arrow}=[->,line width=.05cm,draw=red!90!blue!60!black]

\begin{tikzpicture}[scale=.8]
  \tline{A}{3};
  \tcaption{A}{A};
  \tline{B}{2};
  \tcaption{B}{B};
  \tline{C}{1};
  \tcaption{C}{C};
  \tline{T}{-1.5}
  \tcaption{T}{OS thread};

  \ttimeline{A}{10};
  \ttimeline{B}{10};
  \ttimeline{C}{10};
  \ttimeline{T}{10};

  \tbox{B}{1}{};
  \tcatchup{C}{B};
  %
  \tbox{C}{1}{};
  \tcalloutU[(-.8,2.5)]{C}{\texttt{during(42, routine);}}
  %
  %
  \tcatchup{B}{C};
  \tcatchup{T}{C};
  \draw[arrow] (currentCL) -- node[left] {
    \begin{tabular}{r}
      \one{} create\\thread
    \end{tabular}
  } (currentTU);
  \tbox{T}{4}{\texttt{routine}};
  %
  %
  \tskiptextL{C}{4}{\two{} \texttt{wait(42)}\vspace{-2em}};
  %
  %
  \tbox{B}{1.5}{};
  \tcatchup{A}{B};
  \tbox{A}{1}{};
  \tcatchup{B}{A};
  \tbox{B}{1}{};
  %
  %
  \draw[arrow] (currentTU) -- node[right] {
    \begin{tabular}{l}
      \three{} join\\thread
    \end{tabular}
  } (currentCL);
  \tbox{C}{1}{};
  %
  %
  \tcatchup{A}{C};
  \tbox{A}{1}{};
  \tcatchup{B}{A};
  \tbox{B}{1}{};
  %
\end{tikzpicture}

\section{Arrows between timelines}


\begin{tikzpicture}[scale=.7]
  \tline{sc}{2};
  \tcaption{sc}{SystemC};

  \tline{ace}{0};
  \draw (currentace) ++ (9,-.3) node {Simulated time};

  \tcaption{ace}{P/T Solver};

  \ttimeline{sc}{10};
  \ttimeline{ace}{10};

  \tremember{sc}{before};
  \tlonglighttick{sc};
  \tskip{sc}{1.5};
  \tlonglighttick{sc};
  \tskip{sc}{1.5};
  \tlonglighttick{sc};
  \tskip{sc}{2};
  \trecall{sc}{before};
  \tbox{sc}{6}{Functional (1)};

  \ttextarrowU{sc}{\begin{tabular}{c}
      SystemC reads\\temperature
    \end{tabular}
  };

  \tarrowUL{sc}{ace}{};
  \draw (tmpmid) node[fill=white,inner sep=1pt] {(2)};
  \tremember{ace}{before};
  \tlonglighttick{ace};
  \tskip{ace}{1.5};
  \tlonglighttick{ace};
  \tskip{ace}{1.5};
  \tlonglighttick{ace};
  \tskip{ace}{2};
  \trecall{ace}{before};
  \tbox{ace}{6}{Non-functional (3)};

  \tarrowLU{ace}{sc}{};
  \draw (tmpmid) node[anchor=west] {(4)};

  \tbox{sc}{2}{...};
\end{tikzpicture}

\vspace{1em}

\begin{tikzpicture}[scale=.7]
  \tline{sc}{2};
  \tcaption{sc}{SystemC};

  \tline{ace}{0};
  \tcaption{ace}{P/T Solver};

  \draw (currentace) ++ (9,-.3) node {Simulated time};

  \ttimeline{sc}{10};
  \ttimeline{ace}{10};

  \tbox{sc}{1}{(1)};
  \ttextarrowU{sc}{end of instant $t_{i}$};
  \tcatchup{ace}{sc};
  \coordinate (sceoi) at (currentscL);

  \tskip{sc}{6};
  \ttick{sc};
  \ttextarrowU{sc}{next instant $t_{i+1}$};

  \tarrowCoord{(sceoi)}{(currentaceU)}{};
  \draw (tmpmid) node[anchor=east] {(2)};
  \tbox{ace}{6}{non-functional simu (3)};
  % \tcalloutL{ace}{No IT};
  \ttick{sc};
  \tarrowLU{ace}{sc}{};
  \draw (tmpmid) node[anchor=west] {(4)};
  % \tcalloutU{sc}{Continue};
  \tbox{sc}{1}{...};

\end{tikzpicture}

\section{Events as vertical arrows, mix between timing diagrams and others}

\begin{tikzpicture}
  \tline{S}{6};
  \tline{M}{5};
  \tline{E}{2};
  \tline{T}{0}
  \tline{F}{-2};
  \tline{Eb}{-5};
  \tline{Tb}{-7}

  \coordinate (n1) at (-2.5,-.5);
  \coordinate (n2) at (-2.5,4);
  \draw [decoration={brace,amplitude=10pt},decorate] (n1) to (n2);

  \coordinate (o1) at (-2.5,-7.5);
  \coordinate (o2) at (-2.5,-1.5);
  \draw [decoration={brace,amplitude=10pt},decorate] (o1) to (o2);

  \draw (barycentric cs:n1=.5,n2=.5) ++(-10pt,0) node[anchor=south,rotate=90] {\large\textsf{(a) Naive Temperature Model}};
  \draw (barycentric cs:o1=.5,o2=.5) ++(-10pt,0) node[anchor=south,rotate=90] {\large\textsf{(b) Proposed Approach}};

  \tcaption{S}{Real System};
  \ttimeline{S}{8};

  \tskip{S}{.3};

  \tstartbrace{S};
  \tevent{S}; \tskip{S}{1.5};
  \tevent{S}; \tskip{S}{1.3};
  \tevent{S}; \tskip{S}{1.2};

  \tendbrace{S}{\texttt{f(); wait(40);}};
  \tstartbrace{S};

  \tskip{S}{.2};
  \tevent{S}; \tskip{S}{.8};
  \tevent{S}; \tskip{S}{.7};
  \tevent{S}; \tskip{S}{.5};
  \tevent{S}; \tskip{S}{.5};
  \tevent{S}; \tskip{S}{.8};
  \tevent{S};

  \tendbrace{S}{\texttt{g(); wait(35);}};



  \tcaption{M}{
    \begin{tabular}{r}
      Loosely-Timed\\Model
    \end{tabular}
  };
  \ttimeline{M}{8};
  \tskip{M}{.3};
  \foreach \x in {10,0,-10} {
    \teventA{M}{\x};
  }
  \tskip{M}{4};
  \foreach \x in {25,15,5,-5,-15,-25} {
    \teventA{M}{\x};
  }
  \tskip{M}{2.5};


  \tcaption{E}{Energy};
  \ttimeline{E}{8};

  \draw[red!50!black,thick] (currentE) ++(0,.3) -- ++(.3,0) --
  node[right] {+3} ++(0,.6) -- ++(4,0) --
  node[right] {+6} ++(0,1.2) -- node[near end,below]{total=9} ++(3.5,0)
  ;


  \tcaption{T}{Temperature};

  \ttimeline{T}{8};
  \draw[blue!50!black,thick] (currentT) ++(0,.3) -- ++(.3,0) --
  coordinate[at end](peak1) ++(0,.6) .. controls +(1,-.2) .. ++(4,-.3) --
  coordinate[at end](peak2) ++(0,1) .. controls +(1,-.5) .. ++(3.5,-.8)
  ;



  \draw (peak1) node[draw,circle,thick](peak1){};
  \draw (peak2) node[draw,circle,thick](peak2){};
  \draw (barycentric cs:peak1=.5,peak2=.5) ++(0,.1) node[inner sep=0](peaks){
    \begin{tabular}{c}
      Unrealistic\\peaks
    \end{tabular}
  };
  \draw [arrow] (peaks) -- (peak1);
  \draw [arrow] (peaks) -- (peak2);


  \tcaption{F}{Frequency};
  \ttimeline{F}{8};
  \tskip{F}{.3};
  \tbox{F}{4}{$\frac{3}{40}$ trans/sec};
  \tbox{F}{3.5}{$\frac{6}{35}$ trans/sec};


  \tcaption{Eb}{Energy};
  \ttimeline{Eb}{8};

  \draw[red!50!black,thick] (currentEb) ++(0,.3) -- ++(.3,0) --
  ++(4,.6)
  -- node[at end,right]{total=9} ++(3.5,1.2)
  ;


  \tcaption{Tb}{Temperature};

  \ttimeline{Tb}{8};
  \draw[blue!50!black,thick] (currentTb) ++(0,.3) -- coordinate[at end](start)++(.3,0);
  \path (start)
  ++(4,.6) coordinate (x1)
  ++(3.5,.3) coordinate(x2);
  \draw[blue!50!black,thick,bend left=5] (start) to (x1);
  \draw[blue!50!black,thick,bend left=5] (x1) to (x2);
  ;

\end{tikzpicture}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: