Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. library IEEE;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity lab91 is
  5. port(
  6. PS2_KBCLK : IN std_logic;
  7. PS2_KBDAT : IN std_logic;
  8. CLOCK_50 : IN std_logic;
  9. KEY : IN std_logic_vector(1 downto 0);
  10. LEDR : OUT std_logic_vector(15 downto 0);
  11. HEX6 : OUT std_logic_vector(6 downto 0);
  12. HEX7 : OUT std_logic_vector(6 downto 0)
  13. );
  14. end lab91;
  15.  
  16. architecture a of lab91 is
  17. component ps2_keyboard_to_ascii is
  18. GENERIC(
  19. clk_freq : INTEGER := 50_000_000; --system clock frequency in Hz
  20. ps2_debounce_counter_size : INTEGER := 8);
  21. PORT(
  22. clk : IN STD_LOGIC; --system clock input
  23. ps2_clk : IN STD_LOGIC; --clock signal from PS2 keyboard
  24. ps2_data : IN STD_LOGIC; --data signal from PS2 keyboard
  25. ascii_new : OUT STD_LOGIC; --output flag indicating new ASCII value
  26. ascii_code : OUT STD_LOGIC_VECTOR(6 DOWNTO 0)); --ASCII value
  27. end component;
  28.  
  29. component s7_forps2 is
  30. port (
  31. c: IN std_logic_vector(3 downto 0);
  32. o: OUT std_logic_vector(6 downto 0));
  33. end component;
  34.  
  35. signal ascii : STD_LOGIC_VECTOR(7 DOWNTO 0);
  36. signal asciiN: STD_LOGIC;
  37. signal LED: std_logic_vector(15 downto 0);
  38. signal R : std_logic_vector(3 downto 0);
  39. signal L : std_logic_vector(3 downto 0);
  40. signal rst: std_logic;
  41. begin
  42. ps2: ps2_keyboard_to_ascii port map(CLOCK_50, PS2_KBCLK, PS2_KBDAT, asciiN, ascii(6 downto 0));
  43. rst <= KEY(0);
  44. process(ascii)
  45. begin
  46. R <= ascii(3 downto 0);
  47. L <= '0' & ascii(6 downto 4);
  48.  
  49. end process;
  50.  
  51. LED <= "1000000000000000" when ascii = x"66" else
  52. "0100000000000000" when ascii = x"65" else
  53. "0010000000000000" when ascii = x"64" else
  54. "0001000000000000" when ascii = x"63" else
  55. "0000100000000000" when ascii = x"62" else
  56. "0000010000000000" when ascii = x"61" else
  57. "0000001000000000" when ascii = x"39" else
  58. "0000000100000000" when ascii = x"38" else
  59. "0000000010000000" when ascii = x"37" else
  60. "0000000001000000" when ascii = x"36" else
  61. "0000000000100000" when ascii = x"35" else
  62. "0000000000010000" when ascii = x"34" else
  63. "0000000000001000" when ascii = x"33" else
  64. "0000000000000100" when ascii = x"32" else
  65. "0000000000000010" when ascii = x"31" else
  66. "0000000000000001" when ascii = x"30" else
  67. "0000000000000000" when rst = '0' else
  68. "0000000000000000";
  69.  
  70. LEDR <= LED;
  71. s7_1: s7_forps2 port map(R, HEX6);
  72. s7_2: s7_forps2 port map(L, HEX7);
  73.  
  74. end a;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement