Advertisement
Guest User

sid

a guest
Oct 10th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.75 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity barramento_teclado is
  5.     port
  6.     (
  7.         clk     : in    std_logic;
  8.         coluna  : in    std_logic_vector(3 downto 0);
  9.         linha       : out   std_logic_vector(3 downto 0);
  10.         tecla       : out   std_logic_vector(3 downto 0)
  11.     );
  12. end entity;
  13.  
  14. architecture logic of barramento_teclado is
  15.     type state_type is (s0, s1, s2, s3);
  16.     signal state : state_type;
  17. begin
  18.     process (clk)
  19.     begin
  20.         if (rising_edge(clk)) then
  21.             case state is
  22.                 when s0=>
  23.                     linha <= "1000";
  24.                     if (coluna = "1000") then
  25.                         tecla <= "0000";
  26.                     elsif (coluna = "0100") then
  27.                         tecla <= "0001";
  28.                     elsif (coluna = "0010") then
  29.                         tecla <= "0010";
  30.                     elsif (coluna = "0001") then
  31.                         tecla <= "0011";
  32.                     else
  33.                                 tecla <= "ZZZZ";
  34.                         state <= s1;
  35.                     end if;
  36.                 when s1=>
  37.                     linha <= "0100";
  38.                     if (coluna = "1000") then
  39.                         tecla <= "0100";
  40.                     elsif (coluna = "0100") then
  41.                         tecla <= "0101";
  42.                     elsif (coluna = "0010") then
  43.                         tecla <= "0110";
  44.                     elsif (coluna = "0001") then
  45.                         tecla <= "0111";
  46.                     else
  47.                                 tecla <= "ZZZZ";
  48.                         state <= s2;
  49.                     end if;
  50.                 when s2=>
  51.                     linha <= "0010";
  52.                     if (coluna = "1000") then
  53.                         tecla <= "1000";
  54.                     elsif (coluna = "0100") then
  55.                         tecla <= "1001";
  56.                     elsif (coluna = "0010") then
  57.                         tecla <= "1010";
  58.                     elsif (coluna = "0001") then
  59.                         tecla <= "1011";
  60.                     else
  61.                                 tecla <= "ZZZZ";
  62.                         state <= s3;
  63.                     end if;
  64.                 when s3=>
  65.                     linha <= "0001";
  66.                     if (coluna = "1000") then
  67.                         tecla <= "1100";
  68.                     elsif (coluna = "0100") then
  69.                         tecla <= "1101";
  70.                     elsif (coluna = "0010") then
  71.                         tecla <= "1110";
  72.                     elsif (coluna = "0001") then
  73.                         tecla <= "1111";
  74.                     else
  75.                                 tecla <= "ZZZZ";
  76.                         state <= s0;
  77.                     end if;
  78.             end case;
  79.         end if;
  80.     end process;
  81. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement