Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.numeric_std.all;
- entity hiss is
- port(
- clk : in std_logic;
- g_in, k_in : in std_logic_vector(3 downto 0);
- reset : in std_logic;
- HKL_out, THL_out : out unsigned(3 downto 0);
- motor_out : out unsigned(1 downto 0)
- );
- end hiss;
- architecture Behavioral of hiss is
- signal gin : std_logic_vector (3 downto 0);
- signal kin: std_logic_vector (3 downto 0);
- type tillst_typ is (Vaning1, Vaning2, Vaning3, Vaning4);
- signal nuv, nst : tillst_typ;
- begin
- process (clk)
- begin
- if (rising_edge(clk)) then
- nuv <= nst;
- if (g_in = "1110") then
- nuv <= Vaning1;
- elsif (g_in = "1101") then
- nuv <= Vaning2;
- elsif (g_in = "1011") then
- nuv <= Vaning3;
- elsif (g_in = "0111") then
- nuv <= Vaning4;
- end if;
- end if;
- end process;
- process (nuv, kin,g_in)
- begin
- nst<=nuv;
- motor_out <="00";
- case nuv is
- when vaning1 =>
- THL_out <= "0001" ;
- HKL_out <= "0001" ;
- if (kin = "1101") then
- --nst <= Vaning2;
- motor_out <= "10";
- elsif gin = "1101" then
- motor_out <= "00";
- elsif kin = "1011" then
- motor_out <= "10";
- elsif kin = "0111" then
- motor_out <= "10";
- end if;
- when Vaning2 =>
- THL_out <= "0010";
- HKL_out <= "0010";
- if (kin = "1011") then
- --nst <= Vaning3;
- motor_out <= "10";
- elsif gin = "1011" then
- motor_out <= "00";
- elsif kin = "1110" then
- -- nst <= Vaning1;
- motor_out <= "01";
- elsif kin = "0111" then
- motor_out <= "10";
- end if;
- when Vaning3 =>
- THL_out <= "0100";
- HKL_out <= "0100";
- if (kin = "0111") then
- --nst <= Vaning4;
- motor_out <= "10";
- elsif gin = "0111" then
- motor_out <= "00";
- elsif kin = "1011" then
- --nst <= Vaning3;
- motor_out <= "00";
- elsif kin = "1110" then
- motor_out <= "01";
- elsif kin <= "1101" then
- motor_out <= "01";
- end if;
- when Vaning4 =>
- THL_out <= "1000";
- HKL_out <= "1000";
- if (kin = "1110") then
- --nst <= Vaning1;
- motor_out <= "01";
- elsif gin = "1110" then
- motor_out <= "00";
- elsif kin = "1101" then
- motor_out <= "01";
- elsif kin = "1011" then
- motor_out <= "01";
- end if;
- end case;
- end process;
- process (clk)
- begin
- if rising_edge(clk) then
- if k_in /= "1111" then
- kin<=k_in;
- end if;
- end if;
- end process;
- debouncer: entity work.debounce port map (
- sw => gin(0),
- clk => clk,
- reset => reset,
- db_level => gin(0)
- );
- debouncer1: entity work.debounce port map (
- sw => gin(1),
- clk => clk,
- reset => reset,
- db_level => gin(1)
- );
- debouncer2: entity work.debounce port map (
- sw => gin(2),
- clk => clk,
- reset => reset,
- db_level => gin(2)
- );
- debouncer3: entity work.debounce port map (
- sw => gin(3),
- clk => clk,
- reset => reset,
- db_level => gin(3)
- );
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement