No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Keyboard.vhd 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 01.07.2021 09:09:30
  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. -- Uncomment the following library declaration if using
  23. -- arithmetic functions with Signed or Unsigned values
  24. --use IEEE.NUMERIC_STD.ALL;
  25. -- Uncomment the following library declaration if instantiating
  26. -- any Xilinx leaf cells in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29. entity Keyboard is
  30. Port (CLK : in STD_LOGIC;
  31. PS2Clk : in STD_LOGIC;
  32. PS2Data : in STD_LOGIC;
  33. Data_read : in STD_LOGIC;
  34. Data_av : out STD_LOGIC;
  35. Data : out STD_LOGIC_VECTOR (0 to 6);
  36. alert : out STD_LOGIC);
  37. end Keyboard;
  38. architecture Behavioral of Keyboard is
  39. component KeyboardControler
  40. Port (CLK : in STD_LOGIC;
  41. PS2Clk : in STD_LOGIC;
  42. PS2Data : in STD_LOGIC;
  43. Data_av : out STD_LOGIC;
  44. Data : out STD_LOGIC_VECTOR (0 to 7);
  45. alert : out STD_LOGIC);
  46. end component;
  47. component KeyboardToASCII
  48. Port ( KeyCode : in STD_LOGIC_VECTOR (0 to 7);
  49. CodeASCII : out STD_LOGIC_VECTOR (0 to 6));
  50. end component;
  51. signal buffer_Data : STD_LOGIC_VECTOR (0 to 7);
  52. signal keyboardControleur_Data_av : STD_LOGIC;
  53. signal intern_Data_av : STD_LOGIC := '0';
  54. signal intern_Data : STD_LOGIC_VECTOR (0 to 6) := (others => '0');
  55. begin
  56. instance_KeyboardControler : KeyboardControler
  57. port map (CLK => CLK,
  58. PS2Clk => PS2Clk,
  59. PS2Data => PS2Data,
  60. Data_av => keyboardControleur_Data_av,
  61. Data => buffer_Data,
  62. alert => alert);
  63. instance_KeyboardToASCII : KeyboardToASCII
  64. port map ( KeyCode => buffer_Data,
  65. CodeASCII => intern_Data);
  66. process
  67. begin
  68. wait until CLK'event and CLK = '1';
  69. if (intern_Data_av = '0') then
  70. if (keyboardControleur_Data_av = '1') then
  71. Data <= intern_Data;
  72. intern_Data_av <= '1';
  73. end if;
  74. elsif (Data_read = '1') then
  75. intern_Data_av <= '0';
  76. end if;
  77. end process;
  78. Data_av <= intern_Data_av;
  79. end Behavioral;