schaltfunktionen
play

Schaltfunktionen 1 Teil II.1 Zahlendarstellung 2 b -adische - PowerPoint PPT Presentation

Teil II Schaltfunktionen 1 Teil II.1 Zahlendarstellung 2 b -adische Systeme Sei b I N mit b > 1 und E b = { 0 , 1 , . . . , b 1 } (Alphabet). Dann ist jede Fixpunktzahl z (mit n Vorkomma und k Nachkomma- stellen) mit 0 z b


  1. Teil II Schaltfunktionen 1

  2. Teil II.1 Zahlendarstellung 2

  3. b -adische Systeme Sei b ∈ I N mit b > 1 und E b = { 0 , 1 , . . . , b − 1 } (Alphabet). Dann ist jede Fixpunktzahl z (mit n Vorkomma– und k Nachkomma- stellen) mit 0 ≤ z · b k ≤ b n + k − 1 (und n ∈ I N , k ∈ I N 0 ) eindeutig als Wort der L¨ ange n + k ¨ uber E b darstellbar durch n − 1 z i b i = ( z n − 1 z n − 2 . . . z 0 .z − 1 z − 2 . . . z − k ) b , � z = z i ∈ E b . i = − k • Dezimalsystem: E 10 = { 0 , 1 , . . . , 9 } • Dual– oder Bin¨ arsystem: E 2 = { 0 , 1 } • Oktalsystem: E 8 = { 0 , 1 , . . . , 7 } • Hexadezimalsystem: E 16 = { 0 , 1 , . . . , 9 , A, B, C, D, E, F } 3

  4. Umrechnung Dezimal → Basis b Gegeben: d 10 . . . eine Dezimalzahl (ohne Nachkommastellen) Gesucht: ( z n − 1 z n − 2 . . . z 0 ) b = d 10 Algorithmus: i := 0 // Stelle while d != 0 do // solange d ungleich 0 z[i] := d mod b // Rest von d div b d := d div b // ganzzahlige Division i := i+1 // erh¨ ohe Stelle endwhile 4

  5. Nachkommastellen: Dezimal → Basis b Gegeben: d 10 = (0 .x 1 . . . x k ) 10 : k Nachkommastellen Gesucht: (0 .z 1 . . . z j ) b = d 10 Algorithmus: i := 1 // Stelle while d != 0 do // solange d ungleich 0 z[i] := truncate(d * b) // Vorkommastelle (0 <= z[i] <= b-1) d := d * b - z[i] // Nachkommastellen i := i+1 // erh¨ ohe Stelle endwhile 5

  6. Beispiel 25 . 3 10 0 . 3 ∗ 2 = 0 . 6 z 1 = 0 25 2 = 12 Rest : 1 0 . 6 ∗ 2 = 1 . 2 z 2 = 1 div 12 2 = 6 Rest : 0 0 . 2 ∗ 2 = 0 . 4 z 3 = 0 div 6 2 = 3 Rest : 0 0 . 4 ∗ 2 = 0 . 8 z 4 = 0 div 3 2 = 1 Rest : 1 0 . 8 ∗ 2 = 1 . 6 z 5 = 1 div 1 div 2 = 0 Rest : 1 0 . 6 ∗ 2 = 1 . 2 z 6 = 1 = z 2 . . . 25 . 3 10 = 11001 . 010011001 . . . 2 = 11001 . 01001 2 6

  7. Umrechnung Basis b → Dezimal Gegeben: ( z n − 1 z n − 2 . . . z 0 ) b Gesucht: d 10 = ( z n − 1 z n − 2 . . . z 0 ) b Algorithmus: i := n-1 // Stelle d := 0 // Initialisierung while i >= 0 do // solange i gr¨ osser oder gleich 0 d := b*d + z[i] // berechne n¨ achste Stelle i := i-1 // vermindere Index endwhile Basiert auf der ¨ Aquivalenz (Hornerschema): i =0 z i b i = z 0 + b ( � n − 1 � n − 1 i =1 z i b i − 1 ) = = z 0 + b ( z 1 + b ( . . . b ( z n − 2 + bz n − 1 ) . . . )) 7

  8. Beispiel 0 ∗ 2 + 1 = 1 ∗ 2 + 1 = 3 ∗ 2 + 0 = 6 ∗ 2 + 0 = 12 ∗ 2 + 1 = 25 8

  9. Darstellung negativer Zahlen z = ( z n − 1 . . . z 0 .z − 1 . . . z − k ) 2 eine n + k Dualzahl in Fixpunktdarstellung • Einerkomplement: K 1 ( z ) = ( z n − 1 z n − 2 . . . z 0 .z − 1 . . . z − k ) 2 mit z i = 0 ↔ z i = 1, und z i = z i . • Zweierkomplement: K 2 ( z ) = ( K 1 ( z ) + 1 ulp ) modulo 2 n = 2 n − z • b -Komplement f¨ ur n + k Fixpunktzahlen: K b ( z ) = (˜ z z − 1 ˜ z n − 2 . . . ˜ z 0 . ˜ z − 1 . . . ˜ z − k ) b + 1 ulp 9

  10. Beispiel Bei einer Wortl¨ ange von n = 8 Bits lauten die Darstellungen von +92 und -92 im Einer– bzw. Zweierkomplement: Komplement +92 -92 Einer– dual 01011100 dual 10100011 hexadezimal 5C hexadezimal A3 Zweier– dual 01011100 dual 10100100 hexadezimal 5C hexadezimal A4 10

  11. Subtraktion mit Zweier-Komplement x − y = x + K 2 ( y ) F¨ ur n = 8, berechne 45 − 92 45 = 2 5 + 2 3 + 2 2 + 2 0 : (00101101) 2 + K 2 (92): (10100100) 2 (11010001) 2 = K 2 ( z ) Aus K 2 ( z ) = (11010001) 2 folgt: = K 1 ( K 2 ( z ) − 1 ulp ) z = K 1 ((11010001) 2 − 1) = (00101111) 2 2 5 + 2 3 + 2 2 + 2 1 + 2 0 = 47 = 11

  12. Gleitkommazahlen nach IEEE 754/854 Vorzeichen–Bit ↓ Exponent: l Bit Mantisse: m Bit S e l − 1 e l − 2 . . . . . . . . . e 1 e 0 f m − 1 f m − 2 . . . . . . . . . . . . f 1 f 0 Exponentencharakteristik : E = ( e l − 1 e l − 2 . . . . . . e 1 e 0 ) 2 Mantisse : M = ( f m − 1 f m − 2 . . . . . . f 1 f 0 ) DargestellteZahl : ( − 1) S · (1 .M ) 2 · 2 ( E − E Bias ) 1 ≤ E ≤ 2 · E Bias normalisiert ( − 1) S · (0 .M ) 2 · 2 1 − E Bias E = 0 , M � = 0 denormalisiert ( − 1) S · 0 E = 0 , M = 0 Null mit Vorz. ( − 1) S · ∞ E = 2 · E Bias + 1 , M = 0 ∞ mit Vorz. NaN E = 2 · E Bias + 1 , M � = 0 Not a Number 12

  13. Bereich und Genauigkeit • Mantisse m . . . Genauigkeit • Exponent l − E Bias . . . Gr¨ oße des Zahlenbereichs. Genauigkeit Exponent Mantisse E Bias Bereich Stellen 1 . 5 · 10 − 45 . . . 3 . 4 · 10 38 single: 32 Bit l = 8 m = 23 127 7 – 8 5 . 0 · 10 − 324 . . . 1 . 7 · 10 308 double: 64 Bit l = 11 m = 52 1023 15 – 16 Beispiel: 1 . 0 single Exponent Mantisse 1 . 0 ∗ 2 0 = 1 . 0 ∗ 2 127 − 127 � �� � � �� � = ˆ 0 01111111 00000000000000000000000 = $3 F 800000 double Exponent Mantisse 1 . 0 ∗ 2 0 = 1 . 0 ∗ 2 1023 − 1023 � �� � � �� � = ˆ 0 01111111111 00000 ............... 00000 � �� � 52 Nullen = $3 FF 0000000000000 13

  14. Umwandlung Dezimal → Bin¨ ar • Gegeben: z • Schritt 1: Mantisse M = z ∗ 2 y sodass 1 < = M < 2 • Schritt 2: Exponent E = y + E Bias Beispiel: 2 2 · 1 . 625 6 . 5 = � � 1 + 1 2 + 0 2 2 + 1 2 2 · = 2 3 � � 1 + 1 2 + 0 2 2 + 1 2 129 − 127 · = 2 3 2 129 − 127 · (1 . 101) 2 = = ˆ 0 10000001 10100000000000000000000 = $40 D 00000 . 14

  15. Teil II.2 Boolesche Algebra 15

  16. Boolesche Algebra F¨ ur B = { 0 , 1 } , x, y ∈ B seien folgende Verkn¨ upfungen definiert: x ∪ y := Max( x, y ) , x ∩ y := Min( x, y ) , := 1 − x, x ( B, ∪ , ∩ , ) ist eine Boolesche Algebra 16

  17. Gesetze der Booleschen Algebra a) Kommutativgesetze: x ∪ y = y ∪ x, x ∩ y = y ∩ x b) Assoziativgesetze: ( x ∪ y ) ∪ z = x ∪ ( y ∪ z ) , ( x ∩ y ) ∩ z = x ∩ ( y ∩ z ) c) Verschmelzungsgesetz: ( x ∪ y ) ∩ x = x, ( x ∩ y ) ∪ x = x d) Distributivgesetze: x ∩ ( y ∪ z ) = ( x ∩ y ) ∪ ( x ∩ z ) , x ∪ ( y ∩ z ) = ( x ∪ y ) ∩ ( x ∪ z ) e) Komplementgesetz: x ∪ ( y ∩ y ) = x, x ∩ ( y ∪ y ) = x f) x ∪ 0 = x, x ∩ 0 = 0 , x ∩ 1 = x, x ∪ 1 = 1 g) de Morgansche Regeln: x ∪ y = x ∩ y, x ∩ y = x ∪ y h) x = x ∪ x = x ∩ x = x 17

  18. Potenzmenge F¨ ur B = P ( A ) die Menge aller Teilmengen von A ist ( B, ∪ , ∩ , ) ebenfalls eine Boolesche Algebra 18

  19. Teil II.3 Schaltfunktionen 19

  20. Schaltfunktionen • Schaltfunktion: F : B n → B m ur alle 2 n Inputs gibt es einen eindeutigen • Totale Schaltfunktion: f¨ Output, der alle m Bits belegt. • Boolesche Schaltfunktion: f : B n → B • Komponenten Darstellung: F ( x 1 , . . . , x n ) = ( f 1 ( x 1 , . . . , x n ) , f 2 ( x 1 , . . . , x n ) , . . . , f m ( x 1 , . . . , x n )) . • Anzahl verschiedener Boolescher Funktion: 2 2 n 20

  21. Beispiele • Addition zweier 2 Bit Zahlen: A : B 4 → B 3 A ( x 1 , x 2 , x 3 , x 4 ) = ( a 1 ( x 1 , x 2 , x 3 , x 4 ) , a 2 ( x 1 , x 2 , x 3 , x 4 ) , a 3 ( x 1 , x 2 , x 3 , x 4 )) mit a 1 ( x 1 , x 2 , x 3 , x 4 ) = x 2 ⊕ x 4 a 2 ( x 1 , x 2 , x 3 , x 4 ) = x 1 ⊕ x 3 ⊕ ( x 2 ∧ x 4 ) a 3 ( x 1 , x 2 , x 3 , x 4 ) = ( x 1 ∧ x 3 ) ∨ ( x 1 ∧ x 2 ∧ x 4 ) ( x 3 ∧ x 2 ∧ x 4 ) ∨ • Sortieren von 30 16 Bit Zahlen: S : B 30 ∗ 16 → B 30 ∗ 16 21

  22. Boolesche Funktionen f¨ ur n = 2 (1) x + y x · x x · y x · y x x · y y ⊕ (2) ≡ 0 Min � = Max > x < y (3) ∧ �→ x �← y �↔ ∨ x y f 0 f 1 f 2 f 3 f 4 f 5 f 6 f 7 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 (1) x + y x ⊕ y x + y x + y x · y x + x y x (2) 1 - Max = 1 − y ≥ 1 − x ≤ 1 - Min ≡ 1 (3) ↓ ↔ ¬ y ← ¬ x → ↑ x y f 8 f 9 f 10 f 11 f 12 f 13 f 14 f 15 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 22

  23. Disjunktive Normalform agiger Index zu f : B n → B genau • i = ( i 1 i 2 . . . i n ) 2 ist ein einschl¨ dann wenn f ( i 1 , i 2 , . . . , i n ) 2 = 1 • f¨ ur einen einschl¨ agigen Index i einer Booleschen Funktion f , heißt die Funktion m i ( x 1 , x 2 , . . . , x n ) := x i 1 1 x i 2 2 . . . x i n der i -te Minterm n von f , wobei � falls i j = 1 x j x i j j := falls i j = 0 x j • Darstellungssatz: F¨ ur jede Boolesche Funktion f gilt (DNF): � f = m i . i ∈ I 23

  24. Beispiel Gegeben sei die folgende Boolesche Funktion f : B 3 → B durch die Wertetabelle f ( x 1 , x 2 , x 3 ) i x 1 x 2 x 3 0 0 0 0 0 1 0 0 1 0 2 0 1 0 0 3 0 1 1 1 4 1 0 0 0 5 1 0 1 1 6 1 1 0 0 7 1 1 1 1 Einschl¨ agigen Indizes sind 3, 5, 7. Die zugeh¨ origen Minterme sind: m 3 ( x 1 , x 2 , x 3 ) = x 1 x 2 x 3 m 5 ( x 1 , x 2 , x 3 ) = x 1 x 2 x 3 m 7 ( x 1 , x 2 , x 3 ) = x 1 x 2 x 3 . f ( x 1 , x 2 , x 3 ) = x 1 x 2 x 3 + x 1 x 2 x 3 + x 1 x 2 x 3 24

  25. Funktionale Vollst¨ andigkeit Ein System B = { f 1 , . . . , f n } Boolescher Funktionen heißt (funktional) vollst¨ andig, wenn jede Boolesche Funktion allein durch Einsetzungen bzw. Kompositionen von Funktionen aus B dargestellt werden kann. a) { + , · , } ist funktional vollst¨ andig. b) { + , } ist funktional vollst¨ andig. c) {· , } ist funktional vollst¨ andig. d) { NAND } ist funktional vollst¨ andig. e) { NOR } ist funktional vollst¨ andig. 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend