Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.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 (clk'event and clk='1') 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.                         state <= s1;
  34.                     end if;
  35.                 when s1=>
  36.                     linha <= "0100";
  37.                     if (coluna = "1000") then
  38.                         tecla <= "0100";
  39.                     elsif (coluna = "0100") then
  40.                         tecla <= "0101";
  41.                     elsif (coluna = "0010") then
  42.                         tecla <= "0110";
  43.                     elsif (coluna = "0001") then
  44.                         tecla <= "0111";
  45.                     else
  46.                         state <= s2;
  47.                     end if;
  48.                 when s2=>
  49.                     linha <= "0010";
  50.                     if (coluna = "1000") then
  51.                         tecla <= "1000";
  52.                     elsif (coluna = "0100") then
  53.                         tecla <= "1001";
  54.                     elsif (coluna = "0010") then
  55.                         tecla <= "1010";
  56.                     elsif (coluna = "0001") then
  57.                         tecla <= "1011";
  58.                     else
  59.                         state <= s3;
  60.                     end if;
  61.                 when s3=>
  62.                     linha <= "0001";
  63.                     if (coluna = "1000") then
  64.                         tecla <= "1100";
  65.                     elsif (coluna = "0100") then
  66.                         tecla <= "1101";
  67.                     elsif (coluna = "0010") then
  68.                         tecla <= "1110";
  69.                     elsif (coluna = "0001") then
  70.                         tecla <= "1111";
  71.                     else
  72.                         state <= s0;
  73.                     end if;
  74.             end case;
  75.         end if;
  76.     end process;
  77. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement