Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11:25:56 03/24/2017
  6. -- Design Name:
  7. -- Module Name: Keyboard - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity Keyboard is
  33. Port ( PS2_Clk : in STD_LOGIC;
  34. Clk_50MHz : in STD_LOGIC;
  35. PS2_Data : in STD_LOGIC
  36. );
  37. end Keyboard;
  38.  
  39. architecture Behavioral of Keyboard is
  40.  
  41. signal bitCount : integer range 0 to 100 := 0;
  42. signal scancodeReady : STD_LOGIC := '0';
  43. signal scancode : STD_LOGIC_VECTOR(7 downto 0);
  44. signal breakReceived : STD_LOGIC := '0';
  45.  
  46. constant keyboardUP : STD_LOGIC_VECTOR(7 downto 0) := "00011101";
  47. constant keyboardDOWN : STD_LOGIC_VECTOR(7 downto 0) := "00011011";
  48. constant keyboardRIGHT : STD_LOGIC_VECTOR(7 downto 0) := "00100011";
  49. constant keyboardLEFT : STD_LOGIC_VECTOR(7 downto 0) := "00011100";
  50. begin
  51.  
  52. keyboardCont : process(PS2_Clk)
  53. begin
  54. if falling_edge(PS2_Clk) then
  55. if bitCount = 0 and PS2_Data = '0' then
  56. scancodeReady <= '0';
  57. bitCount <= bitCount + 1;
  58. elsif bitCount > 0 and bitCount < 9 then
  59. scancode <= PS2_Data & scancode(7 downto 1);
  60. bitCount <= bitCount + 1;
  61. elsif bitCount = 9 then
  62. bitCount <= bitCount + 1;
  63. elsif bitCount = 10 then
  64. scancodeReady <= '1';
  65. bitCount <= 0;
  66. end if;
  67. end if;
  68. end process keyboardCont;
  69.  
  70.  
  71.  
  72. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement