Re: Aufgaben und Übungen,

Image automat20240131.jpeg-1

Image automat20240131.jpeg-2

Image automat20240131.jpeg-3

Image automat20240131.jpeg-4

Image automat20240131.jpeg-5

library ieee;
use ieee.std_logic_1164.all;

entity statemachine20240131 is
port (
    z3, z2, z1, z0: in std_logic;
    z3s, z2s, z1s, z0s: out std_logic;
    y1, y0: out std_logic;
    x: in std_logic
);
end;

architecture behaviour of statemachine20240131 is
begin
    z3s <= (z0 and x) or
        (z1 and not x);
    z2s <= (z1 and x) or
        (z2 and not x);
    z1s <= (z0 and not x) or
        (z2 and x);
    z0s <= (z3);
    y1 <= (z0) or
        (z1 and not x) or
        (z2 and x) or
        (z3 and not x);
    y0 <= (z1 and not x) or
        (z3 and not x);
end;

library ieee;
use ieee.std_logic_1164.all;

entity statemachine20240131testbench is
port (
    z3s, z2s, z1s, z0s: out std_logic;
    y1, y0: out std_logic
);
end;

architecture behaviour of statemachine20240131testbench is
    component statemachine20240131
    port (
        z3, z2, z1, z0: in std_logic;
        z3s, z2s, z1s, z0s: out std_logic;
        y1, y0: out std_logic;
        x: in std_logic
    );
    end component;
    signal z3, z2, z1, z0: std_logic;
    signal x: std_logic;
begin
    sm: statemachine20240131 PORT MAP (z3s=>z3s, z2s=>z2s, z1s=>z1s, z0s=>z0s, z3=>z3, z2=>z2, z1=>z1, z0=>z0, x=>x, y1=>y1, y0=>y0);
    z0 <= '1' after 0 ns, '0' after 40 ns;
    z1 <= '0' after 0 ns, '1' after 40 ns, '0' after 80 ns;
    z2 <= '0' after 0 ns, '1' after 80 ns, '0' after 120 ns;
    z3 <= '0' after 0 ns, '1' after 120 ns, '0' after 160 ns;
    x <= '0' after 0 ns, '0' after 10 ns, '1' after 20 ns, '1' after 30 ns, '0' after 40 ns, '0' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns, '0' after 120 ns, '0' after 130 ns, '1' after 140 ns, '1' after 150 ns, '0' after 160 ns;
end;

Image Screenshot_20240131_224451

https://www.ituenix.de/nextcloud/data/dave/files/Documents/david4/2024-01-31/automat20240131.pdf">

https://www.ituenix.de/nextcloud/data/dave/files/Documents/david4/2024-01-31/automat20240131.tex">

// Also, das Programm sieht jetzt so aus

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (void) {
    time_t t;
    int i;

    srand ((int)time (\&amp;t));

    printf ("ZustandttFolge-Zustand fuertAusgangn");
    printf ("ttx=0tx=1tttn");
    for (i = 1;  i <= 8;  i++)
        printf ("%itt%it%itt%itn", i, (rand () % 8) + 1, (rand () % 8) + 1, rand () % 2);

return 0;
}

// Das tut schon mal

# Hier die Ausgabe in der Bash gut darsgestellt

david@laptop-peaq:~\$ ./state
Zustand         Folge-Zustand fuer      Ausgang
                x=0     x=1
1               8       4               1
2               4       5               0
3               4       4               0
4               8       4               1
5               5       8               1
6               4       6               1
7               8       4               0
8               4       2               1
david@laptop-peaq:~\$

Zustand		Folge-Zustand fuer	Ausgang
		x=0	x=1
1		7	6		0
2		2	7		0
3		7	2		0
4		8	5		1
5		4	4		0
6		4	4		0
7		7	3		0
8		8	6		1

So ist es besser

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (void) {
    time_t t;
    int i;

    srand ((int)time (\&amp;t));

    printf ("ZustandttFolge-Zustand fuertAusgangn");
    printf ("tttx=0tx=1ttttn");
    for (i = 1;  i <= 8;  i++)
        printf ("%ittt%it%itttt%in", i, (rand () % 8) + 1, (rand () % 8) + 1, rand () % 2);


return 0;
}

Und ich mache gleich das Beispiel als Übung, vorher das der Fernuni Hagen, aber ohne vor zu stellen

Zustand		Folge-Zustand fuer	Ausgang
			x=0	x=1
1			7	1				0
2			6	5				1
3			2	5				0
4			6	8				1
5			3	8				1
6			4	6				0
7			6	8				0
8			2	2				1

Ok, die Übung der Fernuni Hagen, konnte ich gut machen, jetzt probiere ich es mit meiner eigenen.

Ein nicht sehr gelungenes Beispiel muss ich zu geben, es wurde gleich von Anfang an alles einfach gestrichen, aber na ja, egal. Die n"achste "Ubung vielleicht bessser.

Die -- steht f"ur Streichung. es w"are relativ einfach vielleicht ein Beispiel Programm zu schaffen, was Zust"ande "ubrig l"asst, indem man drei Zust"ande jeweils alle untereinander aufeinander zeigen l"asst.

Zustand Folge-Zustand fuer Ausgang
 x=0 x=1
1 7 1 0
2 6 5 1
3 2 5 0
4 6 8 1
5 3 8 1
6 4 6 0
7 6 8 0
8 2 2 1

0:
Zustand Folge-Zustand fuer Ausgang
 x=0 x=1
1 7 1 0
3 2 5 0
6 4 6 0
7 6 8 0

(1,3) (7,2), (7,5)
(1,6) (7,4), (7,6)
(1,7) (7,6), (7,8)
(3,6) (2,4), (2,6)
(3,7) (2,6), (2,8)
(6,7) (4,6), (4,8)

1:
Zustand Folge-Zustand fuer Ausgang
 x=0 x=1
2 6 5 1
4 6 8 1
5 3 8 1
8 2 2 1

(2,4) (6,6), (6,8)
(2,5) (6,3), (6,8)
(2,8) (6,2), (6,2)
(4,5) (6,3), (6,8)
(4,8) (6,2), (6,2)
(5,8) (3,2), (3,2)

(1,3) (7,2), (7,5)
(1,6) (7,4), (7,6)
(1,7) (7,6), (7,8)
(3,6) (2,4), (2,6)
(3,7) (2,6), (2,8)
(6,7) (4,6), (4,8)
(2,4) (6,6), (6,8)
(2,5) (6,3), (6,8)
(2,8) (6,2), (6,2)
(4,5) (6,3), (6,8)
(4,8) (6,2), (6,2)
(5,8) (3,2), (3,2)

(1,3) (7,2), (7,5)
(1,6) (7,4), (7,6)
(1,7) (7,6), (7,8)
(2,4) (6,6), (6,8)
(2,5) (6,3), (6,8)
(2,8) (6,2), (6,2)
(3,6) (2,4), (2,6)
(3,7) (2,6), (2,8)
(4,5) (6,3), (6,8)
(4,8) (6,2), (6,2)
(5,8) (3,2), (3,2)
(6,7) (4,6), (4,8)

(1,3) (7,2), (7,5)
(1,6) (7,4), (7,6)
(1,7) (7,6), (7,8)
(2,4) (6,8)
(2,5) (6,3), (6,8)
(2,8) (6,2), (6,2)
(3,6) (2,4), (2,6)
(3,7) (2,6), (2,8)
(4,5) (6,3), (6,8)
(4,8) (6,2), (6,2)
(5,8) (3,2), (3,2)
(6,7) (4,6), (4,8)

(1,3) (2,7), (5,7)
(1,6) (5,7), (6,7)
(1,7) (6,7), (7,8)
(2,4) (6,8)
(2,5) (3,6), (6,8)
(2,8) (2,6), (2,6)
(3,6) (2,4), (2,6)
(3,7) (2,6), (2,8)
(4,5) (3,6), (6,8)
(4,8) (2,6), (2,6)
(5,8) (2,3), (2,3)
(6,7) (4,6), (4,8)

(1,3)-- (2,7)--, (5,7)--
(1,6)-- (5,7)--, (6,7)
(1,7)-- (6,7), (7,8)--
(2,4)-- (6,8)--
(2,5)-- (3,6), (6,8)--
(2,8)-- (2,6)--, (2,6)
(3,6)-- (2,4), (2,6)--
(3,7)-- (2,6)--, (2,8)
(4,5)-- (3,6), (6,8)--
(4,8)-- (2,6)--, (2,6)--
(5,8)-- (2,3)--, (2,3)--
(6,7)-- (4,6)--, (4,8)

Gestrichen - alle
(1,3)-- (2,7)--, (5,7)--
(1,6)-- (5,7)--, (6,7)
(1,7)-- (6,7), (7,8)--
(2,4)-- (6,8)--
(2,5)-- (3,6), (6,8)--
(2,8)-- (2,6)--, (2,6)
(3,6)-- (2,4), (2,6)--
(3,7)-- (2,6)--, (2,8)
(4,5)-- (3,6), (6,8)--
(4,8)-- (2,6)--, (2,6)--
(5,8)-- (2,3)--, (2,3)--
(6,7)-- (4,6)--, (4,8)

Gut, diese Übung wäre gemacht - jetzt kommt eine Übung zum Binär zahl umrechnen und in die andere Richtung und die üblichen Aufgaben - auch MIPS Programme schreiben. dazu das übliche

Ich mache auch die Vorbereitungsübungen.