/media/sda-magnetic/david/Dok-15-2023-11-27/fernuni-hagen/cs-i-ii/old-cs-2-02/auswendig-2022-05-11/aufgabe1.txt


Aufgabe 1

a)

DNF:
y <- (not x3 and x2 and not x1) or (x3 and x2 and not x1) or (x1 and x2 and x3)

KNF
y <- (x3 or not x2 or x1) and (not x3 or not x2 or x1) and (not x1 or not x2 or not x3)

b) 

0       1 1 0 1
1       1 0 1 1
2       1 0 0 1
3       0 1 0 1
4       0 1 1 1
5       1 1 1 0
6       1 1 1 1


Gruppe 2:
2       1 0 0 1
3       0 1 0 1
Gruppe 3:
0       1 1 0 1
1       1 0 1 1
4       0 1 1 1
5       1 1 1 0
Gruppe 4:
6       1 1 1 1

2;0     1 - 0 1
2;1     1 0 - 1
3;0     - 1 0 1
3;4     0 1 - 1
0;6     1 1 - 1
1;6     1 - 1 1
4;6     - 1 1 1
5;6     1 1 1 -


3;4     0 1 - 1
2;1     1 0 - 1
0;6     1 1 - 1

3;4;0;6     - 1 - 1
2;1;0;6     1 - - 1

2;0     1 - 0 1
1;6     1 - 1 1

2;0;1;6     1 - - 1

4;6     - 1 1 1
3;0     - 1 0 1

4;6;3;0     - 1 - 1

5;6     1 1 1 -


3;4;0;6     - 1 - 1
2;1;0;6     1 - - 1
5;6         1 1 1 -

            0   1   2   3   4   5   6
3;4;0;6     *           *   *       *
2;1;0;6     *   *   *               *
5;6                             *   *

y <- (x2 and x0) or (x3 and x0) or (x3 and x2 and x1)

0110*
1011*
1111*
1100*
1000*
0000*

            00      01      11      10
            
00          *
01                                  *
11          *               *       
10          *               *

y <- (not x3 and not x2 and not x1 and not x0) or (not x3 and x2 and x1 and not x0) or (x3 and not x1 and not x0) or (x3 and x1 and x0)


Aufgabe 2 

a) 
        _____
     x1-|   |----
        | & |   |
     x2-|   |   |
        -----   |
                |
        _____   |   _____           _____
     x2-|   |   ----|   |-----------|   |---y
        | & |-------| | |           | & |
     x3-|   |   ____|   |   |-------|   |
        -----   |   -----   |       -----
                |           |
        _____   |           |
     x1-|   |---|           |
        | & |               |
     x3-|   |               |
        -----               |
                            |
                            |
                            |
        _____               |
     x4-|   |----------------
        | | |
     x5-|   |
        -----

        
((x1 or x2) and x3) or (x2 and (x3 or x4))


david@www2:~$ gcc wertetabelle.c 
david@www2:~$ ./a.out
x4      x3      x2      x1              y
0       0       0       0               0
0       0       0       1               0
0       0       1       0               0
0       0       1       1               0
0       1       0       0               0
0       1       0       1               1
0       1       1       0               1
0       1       1       1               1
1       0       0       0               0
1       0       0       1               0
1       0       1       0               1
1       0       1       1               1
1       1       0       0               0
1       1       0       1               1
1       1       1       0               1
1       1       1       1               1
david@www2:~$ 


#include <stdio.h>

#define and &&
#define or ||
#define not !

int main (void) {
    int x4, x3, x2, x1;

    printf ("x4\tx3\tx2\tx1\t\ty\n");
    for (x4 = 0;  x4 <= 1;  x4++)
        for (x3 = 0;  x3 <= 1;  x3++)
            for (x2 = 0;  x2 <= 1;  x2++)
                for (x1 = 0;  x1 <= 1;  x1++)
                    printf ("%i\t%i\t%i\t%i\t\t%i\n", x4, x3, x2, x1, ((x1 or x2) and x3) or (x2 and (x3 or x4)));
return 0;
}

c) y <- (x1 and (x2 and x3)) or (x4 and (x2 and x3))

Zweierkomplementdarstellung 5 Bit

00000
11111

00000
1er Komplement
11111
2er Komplement
100000

Das überschreitet 1 Bit, also 

10000 

11111
1er Komplement
00000
2er Komplement 
00001

Die kleinste Zahl ist 00001
Die größte Zahl ist: 10000 im negativen Bereich (also 0)
Im positiven Bereich ist die größte Zahl 01111

23/2 = 11       Rest 1
11/2 = 5        Rest 1
5/2 = 2         Rest 1
2/2 = 1         Rest 0
1/2 = 0         Rest 1

1.0111 

-3/2 = 1        Rest 1
1/2 = 0         Rest 1

11
erweitern
00011
1er Komplement
11100
2er Komplement
11101 

10.1011

32+8+2+1 = 43

01.0110

16+4+2 = 22

if ((A+B) < (1,...,1)) 
    S <- (1,...,1)
else 
    S <- A + B
    
Dabei ist < ein Komperator, dieser hat einen Ausgang, der steuert einen Multiplexer - das ist if - else