Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Library ieee;
- use ieee.std_logic_1164.all;
- entity sequenzerkennung is
- port(
- --low active Reset
- reset, x, clk : in std_logic;
- y : out std_logic;
- leds : out std_logic_vector(8 downto 0)
- );
- end sequenzerkennung;
- architecture bhv of sequenzerkennung is
- type states is (A, B, C, D, E, F, G, H, I);
- --Signals für Neue States (Übergang)
- signal state, new_state : states;
- signal s_x, s_y : std_logic;
- signal s_leds : std_logic_vector(8 downto 0);
- begin
- process(reset, clk)
- begin
- if (reset = '0') then
- state <= A;
- leds <= "000000001";
- y <= '0';
- elsif (rising_edge(clk)) then
- state <= new_state;
- leds <= s_leds;
- y <= s_y;
- s_x <= x;
- end if;
- end process;
- process (state, s_x)
- begin
- s_y <= '0';
- case state is
- when A =>
- if (s_x = '0') then
- new_state <= B;
- s_leds <= "000000010";
- else
- new_state <= F;
- s_leds <= "000100000";
- end if;
- when B =>
- if (s_x = '0') then
- new_state <= C;
- s_leds <= "000000100";
- else
- new_state <= F;
- s_leds <= "000100000";
- end if;
- when C =>
- if (s_x = '0') then
- new_state <= D;
- s_leds <= "000001000";
- else
- new_state <= F;
- s_leds <= "000100000";
- end if;
- when D =>
- if (s_x = '0') then
- new_state <= E;
- s_leds <= "000010000";
- s_y <= '1';
- else
- new_state <= F;
- s_leds <= "000100000";
- end if;
- when E =>
- if (s_x = '0') then
- new_state <= E;
- s_leds <= "000010000";
- else
- new_state <= F;
- s_leds <= "000100000";
- end if;
- when F =>
- if (s_x = '0') then
- new_state <= B;
- s_leds <= "000000010";
- else
- new_state <= G;
- s_leds <= "001000000";
- end if;
- when G =>
- if (s_x = '0') then
- new_state <= B;
- s_leds <= "000000010";
- else
- new_state <= H;
- s_leds <= "010000000";
- s_y <= '1';
- end if;
- when H =>
- if (s_x = '0') then
- new_state <= B;
- s_leds <= "000000010";
- else
- new_state <= I;
- s_leds <= "100000000";
- s_y <= '1';
- end if;
- when I =>
- if (s_x = '0') then
- new_state <= B;
- s_leds <= "000000010";
- else
- new_state <= I;
- s_leds <= "100000000";
- s_y <= '1';
- end if;
- end case;
- end process;
- end bhv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement