Re: Aufgaben und Übungen,

-- Damit tut die Schaltung, hier noch mal

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028ausgangschaltnetz is
port
(
 a, b: in std_logic;
 x: in std_logic;
 y0, y1, y2: out std_logic
);
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028uebergangsschaltnetz is
port
(
 a, b: in std_logic;
 aout, bout: out std_logic;
 x: in std_logic
);
end;

architecture verhalten of meinautomat0028ausgangschaltnetz is
begin
    y0 <= b;
    y1 <= a;
    y2 <= (not b and not a) or (b and a);
end;

architecture verhalten of meinautomat0028uebergangsschaltnetz is
begin
    bout <= b xor a;
    aout <= not a;
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028rslatch is
port (
    q: out std_logic;
    r, s: in std_logic
);
end;

architecture verhalten of meinautomat0028rslatch is
    signal q1, q2 : std_logic;
begin
    q1 <= (r nor q2);
    q2 <= (s nor q1);

    q <= q1;
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028rslatchtaktgesteuert is
port (
    q: out std_logic;
    r, s, c: in std_logic
);
end;

architecture verhalten of meinautomat0028rslatchtaktgesteuert is
    component meinautomat0028rslatch
    port (
        q: out std_logic;
        r, s: in std_logic
    );
    end component;
    signal r1, s1: std_logic;
begin
    instanzrslatch: meinautomat0028rslatch PORT MAP (r=>r1, s=>s1, q=>q);
    r1 <= c and r;
    s1 <= c and s;
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028dlatch is
port
(
    q: out std_logic;
    d, c: in std_logic
);
end;

architecture verhalten of meinautomat0028dlatch is
    component meinautomat0028rslatchtaktgesteuert
    port
    (
        q: out std_logic;
        r, s, c: in std_logic
    );
    end component;
    signal r1, s1: std_logic;
begin
    instanzrslatchtaktgesteuert: meinautomat0028rslatchtaktgesteuert PORT MAP (r=>r1, s=>s1, q=>q, c=>c);
    r1 <= d;
    s1 <= not d;
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028dmasterslaveflipflop is
port
(
    q: out std_logic;
    d, c: in std_logic
);
end;

architecture verhalten of meinautomat0028dmasterslaveflipflop is
    component meinautomat0028dlatch is
    port (
        q: out std_logic;
        d, c: in std_logic
    );
    end component;
    signal c1, c2: std_logic;
    signal d1: std_logic;
begin
    master: meinautomat0028dlatch PORT MAP (q=>d1, d=>d, c=>c1);
    slave: meinautomat0028dlatch PORT MAP (q=>q, d=>d1, c=>c2);
    c1 <= c;
    c2 <= not c;
end;

library ieee;
use ieee.std_logic_1164.all;

entity meinautomat0028schaltwerk is
port
(
    c: in std_logic;
    x: in std_logic;
    we: inout std_logic;
    y0, y1, y2: out std_logic
);
end;

architecture verhalten of meinautomat0028schaltwerk is
    component meinautomat0028dmasterslaveflipflop
    port
    (
        d, c: in std_logic;
        q: out std_logic
    );
    end component;
    component meinautomat0028ausgangschaltnetz
    port
    (
        a, b: inout std_logic;
        x: in std_logic;
        y0, y1, y2: out std_logic
    );
    end component;
    component meinautomat0028uebergangsschaltnetz
    port
    (
        aout, bout: out std_logic;
        a, b: in std_logic;
        x: in std_logic
    );
    end component;
    signal v1, v2 : std_logic;
    signal w1, w2 : std_logic;
    signal p1, p2 : std_logic;
    signal w_1, w_2 : std_logic;
    signal v_1, v_2 : std_logic;
begin
    state1: meinautomat0028dmasterslaveflipflop PORT MAP (d=>w_1, c=>c, q=>v1);
    state2: meinautomat0028dmasterslaveflipflop PORT MAP (d=>w_2, c=>c, q=>v2);
    ausgang: meinautomat0028ausgangschaltnetz PORT MAP (b=>v_1, a=>v_2, x=>x, y0=>y0, y1=>y1, y2=>y2);
    uebergang: meinautomat0028uebergangsschaltnetz PORT MAP (b=>v_1, a=>v_2, bout=>w1, aout=>w2,x=>x);

    w_1 <= w1 when we='1' else '0';
    w_2 <= w2 when we='1' else '0';
    v_1 <= v1 when we='1' else '0';
    v_2 <= v2 when we='1' else '0';

end;

library ieee;
use ieee.std_logic_1164.all;

entity testbench is
    port (
        c: inout std_logic;
        x: inout std_logic;
        y0, y1, y2: out std_logic
    );
end;

architecture verhalten of testbench is
    component meinautomat0028schaltwerk
    port (
        c: in std_logic;
        x: in std_logic;
        we: inout std_logic;
        y0, y1, y2: out std_logic
    );
    end component;
    signal we: std_logic;
begin
    schaltwerk: meinautomat0028schaltwerk PORT MAP (c=>c, x=>x, we=>we, y0=>y0, y1=>y1, y2=>y2);
    c <= '1' after 1 ns, '0' after 2 ns, '1' after 3 ns, '0' after 4 ns,'1' after 5 ns, '0' after 6 ns,'1' after 7 ns, '0' after 8 ns,'1' after 9 ns, '0' after 10 ns, '1' after 11 ns, '0' after 12 ns,'1' after 13 ns, '0' after 14 ns,'1' after 15 ns, '0' after 16 ns;
    --x <= '0' after 1 ns, '0' after 4 ns, '1' after 8 ns, '0' after 12 ns;
    we <= '0' after 0 ns, '1' after 3 ns;
end;