Advertisement
Vedro

Finish him

May 15th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.21 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity Klawiatura is
  5.     Port ( clk_i : in  STD_LOGIC;
  6.            ps2_clk_i : in  STD_LOGIC;
  7.            rst_i : in  STD_LOGIC;
  8.            ps2_data_i : in  STD_LOGIC;
  9.            led7_an_o : out  STD_LOGIC_VECTOR (3 downto 0) := "1110";
  10.            led7_seg_o : out  STD_LOGIC_VECTOR (7 downto 0) := "11111111");
  11. end Klawiatura;
  12.  
  13. architecture Behavioral of Klawiatura is
  14. component F_edge_detector
  15.     Port ( clk_i      : in  std_logic;
  16.              ps2_clk_i  : in  std_logic;
  17.              pulse_o    : out std_logic);
  18. end component;
  19.  
  20. signal DANE : std_logic_vector (7 downto 0);
  21. signal BUFOR : std_logic_vector (10 downto 0);
  22. signal F_EDGE : std_logic;
  23. signal IGNORUJ : std_logic := '0';
  24. --signal NASLUCH : std_logic := '1';
  25. signal i : integer range 0 to 11 := 0;
  26. signal j : integer range 0 to 200 := 0;                                                                         -- zmienić 200 na 2500000 (2 500 000)
  27.  
  28. begin
  29.     led7_an_o <= "1110";
  30.     led7_seg_o(0) <= '1';
  31.     ET1: F_edge_detector port map (clk_i => clk_i, ps2_clk_i => ps2_clk_i, pulse_o => F_EDGE);
  32.        
  33.     Zapis : process (clk_i) is
  34.     begin
  35.         if rising_edge(clk_i) then
  36. --          if NASLUCH = '1' then
  37. --              if ps2_data_i = '0' then
  38. --                  NASLUCH <= '0';
  39. --              end if;
  40. --          else
  41.                 if ps2_clk_i = '1' then
  42.                     j <= 0;
  43.                 end if;
  44.                 if i = 0 then
  45.                     j <= j + 1;
  46.                 end if;
  47.                 if j = 200 then                                                             -- do symulacji 200, normalnie 2500000 (2 500 000)
  48.                     IGNORUJ <= '0';
  49.                 end if;
  50.                
  51.                 if i = 11 then
  52.                     i <= 0;                
  53.                     if BUFOR(8 downto 1) = x"F0" then
  54. --                      NASLUCH <= '1';
  55.                         IGNORUJ <= '1';
  56.                     else
  57.                         if IGNORUJ = '0' then
  58.                             DANE <= BUFOR(8 downto 1);
  59.                         end if;
  60.                         if DANE = x"F0" then
  61.                             IGNORUJ <= '1';
  62.                         end if;
  63.                     end if;
  64.                 elsif F_EDGE = '1' then
  65.                     BUFOR(i) <= ps2_data_i;
  66.                     i <= i + 1;
  67.                 end if;
  68. --          end if;
  69.         end if;
  70.     end process Zapis;
  71.    
  72.     Wyswietlenie : process (rst_i, clk_i) is
  73.     begin
  74.         if (rst_i = '1') then
  75.             led7_seg_o <= "11111111";
  76.         elsif rising_edge(clk_i) then
  77.             if DANE /= x"F0" then
  78.             case DANE is                                                                                   
  79.                 when x"45" => led7_seg_o(7 downto 1) <= "0000001";  --0
  80.                 when x"16" => led7_seg_o(7 downto 1) <= "1001111";  --1
  81.                 when x"1E" => led7_seg_o(7 downto 1) <= "0010010";  --2
  82.                 when x"26" => led7_seg_o(7 downto 1) <= "0000110";  --3
  83.                 when x"25" => led7_seg_o(7 downto 1) <= "1001100";  --4
  84.                 when x"2E" => led7_seg_o(7 downto 1) <= "0100100";  --5
  85.                 when x"36" => led7_seg_o(7 downto 1) <= "0100000";  --6
  86.                 when x"3D" => led7_seg_o(7 downto 1) <= "0001111";  --7
  87.                 when x"3E" => led7_seg_o(7 downto 1) <= "0000000";  --8
  88.                 when x"46" => led7_seg_o(7 downto 1) <= "0000100";  --9
  89.                 when x"1C" => led7_seg_o(7 downto 1) <= "0001000";  --a trzecia litera do symulacji  
  90.                 when x"32" => led7_seg_o(7 downto 1) <= "1100000";  --b
  91.                 when x"21" => led7_seg_o(7 downto 1) <= "0110001";  --c
  92.                 when x"23" => led7_seg_o(7 downto 1) <= "1000010";  --d
  93.                 when x"24" => led7_seg_o(7 downto 1) <= "0110000";  --e    pierwsza litera do symulacji
  94.                 when x"2B" => led7_seg_o(7 downto 1) <= "0111000";  --f  druga litera do symulacji
  95.                 when others => led7_seg_o(7 downto 1) <= "1111111";
  96.             end case;
  97.             end if;
  98.         end if;
  99.     end process;           
  100.  
  101. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement