Oder, wie es einem in der Schule beigebracht wird, noch mal das obige
Beispiel in drei Prozesse Eingabe, Zustandsspeicher und Ausgabe.
Wie man sieht, es ist ein Mealy-Automat ;)
type STATE_TYPE is (IDLE, B1, B2); -- FSM hat 3 States
signal state : STATE_TYPE; -- Signal, welches den aktuellen State
speichert
signal new_state: STATE_TYPE;
-- irgendwelche Datenbytes
constant DATA1 : std_logic_vector(7 downto 0) := x"12";
constant DATA2 : std_logic_vector(7 downto 0) := x"FF";
-- Eingabe-Logik
process(acknowledge, start, state)
begin
case state is
when IDLE =>
if start = '1' then
new_state <= IDLE;
end if;
when B1 =>
new_state <= B2;
when B2 =>
if acknowledge = '1' then
new_state <= IDLE;
end if;
when others => new_state <= IDLE;
end case;
end process
-- Zustandsspeicher
process(reset, clk, new_state)
begin
if reset = '1' then
state <= IDLE;
elsif clk = '1' and clk'event then
state <= new_state;
end if;
end process;
-- Ausgabe-Logik
process(state, start)
begin
case state is
when IDLE =>
if start = '1' then
d_out <= DATA1;
end if;
when B1 =>
d_out <= DATA2;
when others => null;
end case;
end process;