This is an old revision of the document!
VHDL Code für Zustandsautomaten
Zustandsautomaten können sehr elegant in VHDL beschrieben werden.
Hier ein Automat, der die Sequenz “101” erkennt und dann am Ausgang eine “1” ausgibt. Ein Moore Automat entsteht, wenn die Ausgangssignale nur vom State und nicht vom Eingangssignal abhängen.
library ieee; use ieee.std_logic_1164.all; entity automat is port ( clk_i: in std_ulogic; reset_ni: in std_ulogic; in_i: in std_ulogic; out_o: out std_ulogic ); end; architecture rtl of edge is type state_type is (start_s, erste_eins_s, null_in_der_mitte_s, fertig_s); signal current_state, next_state : state_type; begin next_state_and_output_p : process(current_state, in_i) begin out_o <= '0'; next_state <= current_state; case current_state is when start_s => if in_i = '1' then next_state <= erste_eins_s; end if; when erste_eins_s => if in_i = '0' then next_state <= null_in_der_mitte_s; else next_state <= erste_eins_s; end if; when null_in_der_mitte_s => if in_i = '1' then next_state <= fertig_s; else next_state <= start_s; end if; when fertig_s => out_o <= '1'; if in_i = '1' then next_state <= erste_eins_s; else next_state <= start_s; end if; end case; end process next_state_and_output_p; -- The sequential process for flipflop instantiation -- All signal assignments in this process will result in flipflops. state_reg_p : process (clk_i, reset_ni) begin if reset_ni = '0' then current_state <= start_s; elsif rising_edge(clk_i) then current_state <= next_state; end if; end process state_reg_p; end architecture;