summaryrefslogtreecommitdiff
path: root/dt-zahlensysteme.tex
blob: 0560ee024f8f836f67f5d5a5eef76ff0e679d212 (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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
% !TEX root = dt-slides-dt.tex

\section{Zahlenkodierung}

\begin{frame}
\frametitle{Zahlenkodierung}
\center
\Huge Zahlenkodierung
\end{frame}

\begin{frame}
\frametitle{Zahlendarstellung - Vorzeichenlose Zahlen - Dualdarstellung}
\begin{columns}
\column[T]{0.3\textwidth}
\begin{tabular}{c|c}
Binärcode & Vorzeichenlos\\\hline
0000 & 0   \\
0001 & 1   \\
0010 & 2   \\
0011 & 3   \\
0100 & 4   \\
0101 & 5   \\
0110 & 6   \\
0111 & 7   \\
1000 & 8   \\
1001 & 9   \\
1010 & 10  \\
1011 & 11  \\
1100 & 12  \\
1101 & 13   \\
1110 & 14 \\
1111 & 15
\end{tabular}
\column[T]{0.7\textwidth}
\begin{equation*}
z_{n-1} z_{n-2} ... z_{1} z_{0} = z_{n-1} \cdot 2^{n-1} +  z_{n-2} \cdot 2^{n-2} + ... + z_{1} \cdot 2^{1} + z_{0} \cdot 2^{0} 
\end{equation*}

\begin{block}{Wertebereich: n-Bit Zahl}
Mit einer n-Bit vorzeichenlosen Zahl lassen sich Zahlen im Bereich 0 bis $2^n-1$ darstellen.
\end{block}
\end{columns}
\end{frame}

\begin{frame}
\frametitle{Zahlenkreis - Vorzeichenlose Zahlen - Addition}
\begin{tikzpicture}[scale=0.7]
\foreach \dez / \bin / \zahl in 
{0/0000/0, 1/0001/1, 2/0010/2, 3/0011/3, 4/0100/4, 5/0101/5, 6/0110/6, 7/0111/7, 8/1000/-8, 9/1001/-7, 10/1010/-6,
11/1011/-5, 12/1100/-4, 13/1101/-3, 14/1110/-2, 15/1111/-1}
{
\draw (90 - \dez * 22.5:4) node {\bin};
\draw (90 - \dez * 22.5:3) node {\dez};
%\draw (90 - \dez * 22.5:5) node {\zahl};
}
%\draw[->, blue, thick] (90:4.5) arc[start angle = 90, end angle = 90 - 7 * 22.5 , radius=4.5] ;
%\draw[->, red, thick] (90:4.5) arc (90:270:4.5);
\draw[->, green, thick] (90:3.5) arc (90:-250:3.5);
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Zahlenkreis - Sign/Magnitude - Betrags- / Vorzeichendarstellung}
\begin{tikzpicture}[scale=0.7]
\foreach \dez / \bin / \zahl in 
{0/0000/0, 1/0001/1, 2/0010/2, 3/0011/3, 4/0100/4, 5/0101/5, 6/0110/6, 7/0111/7, 8/1000/-0, 9/1001/-1, 10/1010/-2,
11/1011/-3, 12/1100/-4, 13/1101/-5, 14/1110/-6, 15/1111/-7}
{
\draw (90 - \dez * 22.5:4) node {\bin};
\draw (90 - \dez * 22.5:3) node {\dez};
\draw (90 - \dez * 22.5:5) node {\zahl};
}
%\draw[->, blue, thick] (90:4.5) arc[start angle = 90, end angle = 90 - 7 * 22.5 , radius=4.5] ;
%\draw[->, red, thick] (90:4.5) arc (90:270:4.5);
\draw[->, green, thick] (90:3.5) arc (90:-250:3.5);
\end{tikzpicture}
\end{frame}

\begin{frame}
\frametitle{Zahlenkreis - Zweierkomplement}
\begin{columns}
\column[T]{0.5\textwidth}
\begin{tikzpicture}[scale=0.6]
\foreach \dez / \bin / \zahl in 
{0/0000/0, 1/0001/1, 2/0010/2, 3/0011/3, 4/0100/4, 5/0101/5, 6/0110/6, 7/0111/7, 8/1000/-8, 9/1001/-7, 10/1010/-6,
11/1011/-5, 12/1100/-4, 13/1101/-3, 14/1110/-2, 15/1111/-1}
{
\draw (90 - \dez * 22.5:4) node {\bin};
\draw (90 - \dez * 22.5:3) node {\dez};
\draw (90 - \dez * 22.5:5) node {\zahl};
}
\draw[->, blue, thick] (90:4.5) arc[start angle = 90, end angle = 90 - 7 * 22.5 , radius=4.5] ;
\draw[->, red, thick] (90:4.5) arc (90:270:4.5);
\draw[->, green, thick] (90:3.5) arc (90:-250:3.5);
\end{tikzpicture}
\column[T]{0.5\textwidth}
\begin{block}{Wertebereich: n-Bit Zweierkomplementzahl}
Mit einer n-Bit Zahl im Zweierkomplement lassen sich Zahlen im Bereich $-2^{n-1}$ bis $2^{n-1}-1$ darstellen.
\end{block}

\begin{block}{Kodierung Zahl im Zweierkomplement}
Positive Zahlen wie Vorzeichenlose Zahlen kodiert. Negative Zahlen werden durch das Zweierkomplement des Betrags der Zahl dargestellt.
\end{block}

\begin{block}{Zweierkomplement}
Das Zweierkomplement einer Zahl x ist $R-x$. R ist $2^n$ für eine n-Bit Zahl. Bei einer 4 Bitzahl ist R = $2^4=16$. Die Zahl -3 wird als 16 - 3 = 13 = 1101 kodiert.
\end{block}

\end{columns}
\end{frame}

\begin{frame}
\frametitle{Zweierkomplement - Alternative Berechnung }
\begin{tabular}{rccccccc}
$X = $ & & $x_{n-1}$ & $x_{n-2}$ & ... & $x_1$ & $x_0$  & \\
+ $\overline{X} = $ & & $\overline{x_{n-1}}$ & $\overline{x_{n-2}}$ & ... & $\overline{x_1}$ & $\overline{x_0}$ & \\\hline
 & & 1  & 1 & ... & 1 & 1 & \\
+1$_D$ & & 0  & 0 & ... & 0 & 1 & \\\hline
 & 1 & 0 & 0 & ... & 0 & 0 & $= 2^n = R$ \\
\end{tabular}

\begin{align}
& X + \overline{X} + 1_D = 2^n = R \label{equ:alter2} \\
\iff & \overline{X} + 1_D = R - X = 2er(X) \label{equ:alttwo}
\end{align}

\begin{block}{Zweierkomplement}
Das Zweierkomplement kann durch die zwei Schritte 
\begin{enumerate}
\item Bitweises Invertieren
\item Addieren von +1
\end{enumerate}
berechnet werden.
\end{block}

\begin{block}{Umkehrfunktion 2er Komplement }
\begin{equation}
2er(2er(X)) = R - (R - X)  = X \Rightarrow 2er^{-1}(X) = 2er(X) \label{equ:umk2}
\end{equation}
\end{block}


\end{frame}

\begin{frame}
\frametitle{Zahlenkreis - Zweierkomplement - Addition}
\begin{tikzpicture}[scale=0.8]
\foreach \dez / \bin / \zahl in 
{0/0000/0, 1/0001/1, 2/0010/2, 3/0011/3, 4/0100/4, 5/0101/5, 6/0110/6, 7/0111/7, 8/1000/-8, 9/1001/-7, 10/1010/-6,
11/1011/-5, 12/1100/-4, 13/1101/-3, 14/1110/-2, 15/1111/-1}
{
\draw (90 - \dez * 22.5:4) node {\bin};
\draw (90 - \dez * 22.5:3) node {\dez};
\draw (90 - \dez * 22.5:5) node {\zahl};
}
\draw[->, blue, thick] (90:4.5) arc[start angle = 90, end angle = 90 - 7 * 22.5 , radius=4.5] ;
\draw[->, red, thick] (90:4.5) arc (90:270:4.5);
\draw[->, green, thick] (90:3.5) arc (90:-250:3.5);
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Zahlendarstellung}
\begin{tabular}{c|ccc}
Binärcode & Vorzeichenlos & Sign/Magnitude & Zweierkomplement \\\hline
0000 & 0 & 0 & 0  \\
0001 & 1 & 1 & 1  \\
0010 & 2 & 2 & 2  \\
0011 & 3 & 3 & 3  \\
0100 & 4 & 4 & 4  \\
0101 & 5 & 5 & 5  \\
0110 & 6 & 6 & 6  \\
0111 & 7 & 7 & 7  \\
1000 & 8 & -0 & -8  \\
1001 & 9 & -1 & -7  \\
1010 & 10 & -2 & -6  \\
1011 & 11 & -3 & -5  \\
1100 & 12 & -4 & -4  \\
1101 & 13 & -5 & -3  \\
1110 & 14 & -6 & -2  \\
1111 & 15 & -7 & -1  
\end{tabular}

\end{frame}


\begin{frame}
\frametitle{Hexadezimalzahlen - Basis 16}
\begin{equation}
1F2_H =  1 \cdot 16^2 + 15 \cdot 16^1 + 2 \cdot 16^0 =  1 \cdot 256 + 15 \cdot 16 + 2 \cdot 1  = 498_D \label{equ:hexsys}
\end{equation}

\vspace{2cm}

\center
\begin{tikzpicture}
\draw (0,0) node {$498_D = $} ++(right:1.5) node (z2) {0001};
\draw (z2.east) ++(right:0.001) node[anchor=west] (z1) {1111};
\draw (z1.east) ++(right:0.001) node[anchor=west] (z0) {$0010_B$};

\draw (z2.south) -- ++ (down:1) node[anchor=north] {1};
\draw (z1.south) -- ++ (down:1) node[anchor=north] {F};
\draw (z0.south) -- ++ (down:1) node[anchor=north] {$2_H$};
\end{tikzpicture} 
\end{frame}

\section{Arithmetische Schaltungen}

\begin{frame}
\frametitle{Arithmetische Schaltungen}
\center
\Huge Arithmetische Schaltungen
\end{frame}

\subsection{Carry Ripple Adder}

\begin{frame}
\frametitle{Carry Ripple Adder - Schulrechenmethode}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{tabular}{rr}
28 = & 11100 \\
+22 = & 10110 \\\hline
Übertrag (Carry) =   &  111000  \\\hline
Summe = & 110010
\end{tabular}

\vspace{1cm}

\begin{tikzpicture}
\draw (0,1.5)
\foreach \i in {3, 2, 1, 0}
{
++(right:1) node (a\i) {$a_\i$}
};
\draw (0,1)
\foreach \i in {3, 2, 1, 0}
{
++(right:1) node (b\i) {$b_\i$}
};
\draw (0,0.5)
\foreach \i in {3, 2, 1, 0}
{
++(right:1) node (c\i) {$c_\i$}
};
\draw (0,-0.25)
\foreach \i in {3, 2, 1, 0}
{
++(right:1) node (s\i) {$s_\i$}
};
\draw (0,0.75) -- (5,0.75);
\draw (0,0.25) -- (5,0.25);
\draw[orange, thick] (a0.north west) -- (a0.north east) -- (b0.south east) -- (b0.south west) -- (a0.north west);
\draw[orange, ->, thick] (b0.south west) -- (c1);
\draw[orange, ->, thick] (b0.south) -- (s0);
\draw[magenta, thick] (a1.north west) -- (a1.north east) -- (c1.south east) -- (c1.south west) -- (a1.north west);
\draw[magenta, ->, thick] (c1) -- (c2);
\draw[magenta, ->, thick] (c1) -- (s1);

\draw (a0.north) -- ++(105:0.5) node[anchor=south west]{Halbaddierer};
\draw (a1.north west) -- ++(125:1) node[anchor=south ]{Volladdierer};
\end{tikzpicture}
\end{column}
\begin{column}{0.5\textwidth}
\pause
\begin{block}{Halbaddierer}
\begin{columns}
\begin{column}{0.5\textwidth}
\center
\begin{tabular}{cc|cc}
a & b & c & s \\\hline
0 & 0 & 0 & 0\\
0 & 1 & 0 & 1\\
1 & 0 & 0 & 1\\
1 & 1 & 1 & 0
\end{tabular}
\end{column}
\begin{column}{0.5\textwidth}
\begin{align}
c &= a \cdot b \nonumber\\
s &= a \oplus b  \nonumber
\end{align}
\end{column}
\end{columns}
\end{block}
\pause
\begin{block}{Volladdierer}
\center
\begin{tabular}{ccc|cc}
a  & b & $c_i$ & $c_o$ & s\\\hline
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 1\\
0 & 1 & 0 & 0 & 1\\
0 & 1 & 1 & 1 & 0 \\
1 & 0 & 0 & 0 & 1\\
1 & 0 & 1 & 1 & 0\\
1 & 1 & 0 & 1 & 0 \\
1 & 1 & 1 & 1 & 1\\
\end{tabular}
\pause
\begin{align}
c_o &= a \cdot (b \oplus c_i) + b \cdot c_i \nonumber \\
s &= a \oplus b \oplus c_i \nonumber
\end{align}
\end{block}

\end{column}
\end{columns}

\end{frame}

\begin{frame}
\frametitle{Carry Ripple Adder}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\draw (8,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (ha) {HA};
\draw (5,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va1) {VA};
\draw (2,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va2) {VA};
\draw (-1,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va3) {VA};
\draw (ha.north east) ++(left:0.5) -- ++(up:0.5) node [anchor=south] {$b_0$}  ++(down:1) node[anchor=south] {$b$};
\draw (ha.north west) ++(right:0.5) -- ++(up:0.5) node [anchor=south] {$a_0$}  ++(down:1) node[anchor=south] {$a$};
\draw (ha.west) node[anchor=west] {$c_o$};
\draw (ha.south) node[anchor=south] {$s$} -- ++(down:1) node[anchor=north] {$s_0$};
\foreach \i in {1,2,3}
{
\draw (va\i.north east) ++(left:0.5) -- ++(up:0.5) node [anchor=south] {$b_\i$} ++(down:1) node[anchor=south] {$b$};
\draw (va\i.north west) ++(right:0.5) -- ++(up:0.5) node [anchor=south] {$a_\i$} ++(down:1) node[anchor=south] {$a$};
\draw (va\i.west) node[anchor=west] {$c_o$};
\draw (va\i.east) node[anchor=east] {$c_i$};
\draw (va\i.south) node[anchor=south] {$s$} -- ++(down:1) node[anchor=north] {$s_\i$};
\draw (va\i.east) -- node[above] {$c_\i$}++(right:1);
}
\end{tikzpicture} 
\begin{block}{Komplexität n-Bit Addition: 5n-3 Gatter}
Für eine Addition von zwei n-Bit Zahlen mit dem Carry Ripple Adder werden 5n-3 Gatter benötigt. In Bezug auf die Anzahl der Gatter ist die Addition also in der Klasse der linearen Komplexität. Die Schaltungstiefe wird durch die Überträge (Carry) bestimmt und steigt linear mit n. Daher der Name "Carry-Ripple", weil bei einer Änderung der niederwertigen Bits das Übertragsbit durch die gesamte Schaltung "ripplen" kann. Der Carry Ripple Adder ist die Schaltung mit der kleinsten möglichen Anzahl von Gattern für die Addition. 
\end{block}
\end{frame}

\begin{frame}
\frametitle{Multiplikation mit -1 = 2er Komplement}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\draw (0,0) node[rectangle, draw, minimum width = 2cm, minimum height = 8cm] (cra) {+};
\draw (cra.north west)
\foreach \i in {3,2,1,0}
{
++(down:1) node[anchor=west] (craa\i) {$a_\i$}
};
\draw (cra.south west)
\foreach \i in {0,1,2,3}
{
++(up:0.5) node[anchor=west] (crab\i)  {$b_\i$}
};
\draw (cra.east) ++(down:1.25)
\foreach \i in {0,1,2,3}
{
++(up:0.5) node[anchor=east] (cray\i) {$y_\i$}
};
\foreach \i in {0,1,2,3}
{
\draw (cray\i) -- ++(right:1) node[anchor=west] {$y_\i$};
\draw (craa\i) -- ++(left:1) node[not gate, anchor=output] (inv\i) {};
\draw (inv\i.input) -- ++(left:1) node[anchor=east] {$x_\i$};
}
\foreach \i in {1,2,3}
{
\draw (crab\i) -- ++(left:1) node[anchor=east] {0};
}
\draw (crab0) -- ++(left:1) node[anchor=east] {1};
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Subtrahierer}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\draw (8,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va0) {VA};
\draw (5,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va1) {VA};
\draw (2,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va2) {VA};
\draw (-1,0) node[rectangle, draw, minimum width = 2cm, minimum height = 2cm] (va3) {VA};

\foreach \i in {0,1,2,3}
{
\draw (va\i.north east) ++(left:0.5) ++(up:0.1) circle (0.1) ++(up:0.1) -- ++(up:0.3) node [anchor=south] {$b_\i$} ++(down:1) node[anchor=south] {$b$};
\draw (va\i.north west) ++(right:0.5) -- ++(up:0.5) node [anchor=south] {$a_\i$} ++(down:1) node[anchor=south] {$a$};
\draw (va\i.west) node[anchor=west] {$c_o$};
\draw (va\i.east) node[anchor=east] {$c_i$};
\draw (va\i.south) node[anchor=south] {$s$} -- ++(down:1) node[anchor=north] {$s_\i$};
\draw (va\i.east) -- node[above] {$c_\i$}++(right:1);
}
\draw (va0.east) ++(right:1) node[anchor=west] {1};

\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Sign Extension - Stellenerweiterung Vorzeichenlos}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\foreach \i in {4,3,2,1,0}
{
\draw (0,\i) node[anchor=east] {$x_\i$}  -- ++(right:5)  node[anchor=west] {$y_\i$};
}
\foreach \i in {7,6,5}
{
\draw (4,\i) node[anchor=east] {0} -- ++(right:1) node[anchor=west] {$y_\i$};
}
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Sign Extension - Stellenerweiterung Zweierkomplement}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\foreach \i in {4,3,2,1,0}
{
\draw (0,\i) node[anchor=east] {$x_\i$}  -- ++(right:5)  node[anchor=west] {$y_\i$};
}
\draw (4,4) node[contact] (c) {};
\draw (4,5) node[contact] {} -- ++(right:1) {};
\draw (4,6) node[contact] {} -- ++(right:1) {};
\draw (5,7) -| (c);
\foreach \i in {7,6,5}
{
\draw (5,\i) node[anchor=west] {$y_\i$};
}
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Arithmetisches Schieben nach Links - Multiplikation mit Zwei}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\foreach \i in {0,1,2}
{
\newcount\mycount
\mycount=\numexpr(\i+1)
\draw (0,\i) node[anchor=east] {$x_\i$} -- ++(right:4-\i)  -- ++(1,1) -- ++(right:3) -- ++(right:\i) node[anchor=west] {$y_\the\mycount$};
}
\draw (8,0) node[anchor=west] {$y_0$} -- ++(left:1) node[anchor=east] {0};
\draw (0,3) node[anchor=east] {$x_3$};
\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Arithmetisches Schieben nach Rechts - Zweierkomplement - Division durch Zwei}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\foreach \i in {3,2,1}
{
\newcount\mycount
\mycount=\numexpr(\i-1)
\draw (0,\i) node[anchor=east] {$x_\i$} -- ++(right:1+\i)  -- ++(1,-1) -- ++(right:5-\i)  node[anchor=west] {$y_\the\mycount$};
}
\draw (7,3) node[anchor=west] {$y_3$} -- ++(left:3) node[contact] {};
\draw (0,0) node[anchor=east] {$x_0$};

\end{tikzpicture} 

\end{frame}

\begin{frame}
\frametitle{Arithmetisches Schieben nach Rechts - Vorzeichenlos - Division durch Zwei}
\begin{tikzpicture}[circuit logic IEC, circuit ee IEC]
\foreach \i in {3,2,1}
{
\newcount\mycount
\mycount=\numexpr(\i-1)
\draw (0,\i) node[anchor=east] {$x_\i$} -- ++(right:1+\i)  -- ++(1,-1) -- ++(right:5-\i)  node[anchor=west] {$y_\the\mycount$};
}
\draw (7,3) node[anchor=west] {$y_3$} -- ++(left:1) node[anchor=east] {0};
\draw (0,0) node[anchor=east] {$x_0$};

\end{tikzpicture} 
\end{frame}

\begin{frame}
\frametitle{Zahlenvergleich gegen Konstante}
\begin{block}{Vergleich gegen Konstante als Minterm}
Ein Vergleich einer Zahl auf eine Konstante kann als Minterm implementiert werden.
\end{block}
Beispiel: X ist eine 4 Bit vorzeichenlose Zahl. Wie kann man testen ob $X = 13_D = 1101_B$ ist?
\begin{equation*}
y = f(x) = \left\{
\begin{array}{ll}
0 & \textrm{wenn}\, x \neq 13\\
1 & \textrm{wenn}\, x = 13\\
\end{array}
\right. 
\end{equation*}
\begin{center}
\begin{tabular}[t]{cc}
Idee: Minterm, der bei 1101 den Wert '1' hat: &  \\
&
\begin{circuitikz}
\draw node[european and port, number inputs = 4] (a0) {};
\draw (a0.bin 3) node[notcirc, anchor = right] {};
\draw (a0.in 1) node[anchor=east] {$x_3$};
\draw (a0.in 2) node[anchor=east] {$x_2$};
\draw (a0.in 3) node[anchor=east] {$x_1$};
\draw (a0.in 4) node[anchor=east] {$x_0$};
\draw (a0.out) node[anchor=west] {$y$};
\end{circuitikz}
\end{tabular}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Zahlenvergleich negative Zahl}
\begin{block}{Test $X < 0$ ist das MSB der Zweierkomplementzahl}
Im Zweierkomplementcode ist die Zahl negativ, wenn das höchstwertige Bit '1' ist.
\end{block}
Beispiel: X ist eine 8 Bit Zahl im Zweierkomplement. Wie kann man testen ob $X < 0_D$ ist?
\begin{equation*}
y = f(x) = \left\{
\begin{array}{ll}
0 & \textrm{wenn}\, x \geq 0_D\\
1 & \textrm{wenn}\, x < 0_D\\
\end{array}
\right. 
\end{equation*}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node (x7) {$x_7$} 
\foreach \i in {6,5,...,0} {
++(down:0.3) node {$x_\i$}
}
;
\draw (x7.east) -- ++(right:3) node[anchor=west] {$y$};
\end{tikzpicture}
\end{center}
\end{frame}


\begin{frame}
\frametitle{Zahlenvergleich allgemein}
\begin{block}{Test $X < K$ wird auf $... < 0$ zurückgeführt }
Die Ungleichung $X < K$ wird umgeformt bis auf $... < 0$ getestet wird. Dazu ist eine Addition oder Subtraktion notwendig.
\end{block}
Beispiel: X ist eine 4 Bit Zahl im Zweierkomplement. Wie kann man testen ob $X < K$ ist?
\begin{align*}
X &< K & |-K\\
X - K &< 0
\end{align*}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node[rectangle, draw, minimum width = 2cm, minimum height = 4cm] (cra) {-};
\draw (cra.north west)
\foreach \i in {3,2,1,0}
{
++(down:0.3) node[anchor=west] (craa\i) {$a_\i$} -- +(left:1) node[anchor=east] {$x_\i$}
};
\draw (cra.south west)
\foreach \i in {0,1,2,3}
{
++(up:0.3) node[anchor=west] (crab\i)  {$b_\i$} -- +(left:1) node[anchor=east] {$k_\i$}
};
\draw (cra.east) ++(down:0.6)
\foreach \i in {0,1,2,3}
{
++(up:0.3) node[anchor=east] (cray\i) {$y_\i$} 
};
\draw (cray3.east) -- +(right:1) node[anchor=west] {y};

\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Beispiel: Berechnung des Betrags}
\begin{block}{Beispiel: Berechnung des Betrags}
Entwerfen Sie eine Schaltung, die den Betrag $y=|x|$ berechnet. Verwenden Sie Addierer, Multiplexer und Grundgatter nach Bedarf. Nehmen Sie eine Bitbreite von 8 an.
\end{block}
\vspace{0.9\textheight}

\end{frame}