Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3. USE ieee.numeric_std.all; -- needed for 'unsigned'
  4.  
  5. ENTITY hex7seg IS
  6. PORT (
  7. hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  8. display : OUT STD_LOGIC_VECTOR(0 TO 6));
  9. END hex7seg;
  10.  
  11. ARCHITECTURE Behavior OF hex7seg IS
  12. BEGIN
  13. --
  14. -- 0
  15. -- ---
  16. -- | |
  17. -- 5| |1
  18. -- | 6 |
  19. -- ---
  20. -- | |
  21. -- 4| |2
  22. -- | |
  23. -- ---
  24. -- 3
  25. --
  26. PROCESS ( hex)
  27. BEGIN
  28. CASE hex IS
  29. WHEN "0000" => display <= "0000001";
  30. WHEN "0001" => display <= "1001111";
  31. WHEN "0010" => display <= "0010010";
  32. WHEN "0011" => display <= "0000110";
  33. WHEN "0100" => display <= "1001100";
  34. WHEN "0101" => display <= "0100100";
  35. WHEN "0110" => display <= "0100000";
  36. WHEN "0111" => display <= "0001111";
  37. WHEN "1000" => display <= "0000000";
  38. WHEN "1001" => display <= "0000100";
  39. WHEN "1010" => display <= "0001000";
  40. WHEN "1011" => display <= "1100000";
  41. WHEN "1100" => display <= "0110001";
  42. WHEN "1101" => display <= "1000010";
  43. WHEN "1110" => display <= "0110000";
  44. WHEN "1111" => display <= "0111000";
  45. WHEN OTHERS => display <= "1111111"; -- empty
  46. END CASE;
  47. END PROCESS;
  48. END Behavior;
  49.  
  50. ----------------------------------------------------
  51. LIBRARY ieee;
  52. USE ieee.std_logic_1164.all;
  53. USE ieee.numeric_std.all; -- needed for 'unsigned'
  54.  
  55. entity DemoSSD is
  56. port ( CLOCK_50: in std_logic;
  57. SW: in std_logic_vector (17 downto 0);
  58. LEDR: out std_logic_vector (17 downto 0);
  59. KEY: in std_logic_vector (3 downto 0);
  60. LEDG: out std_logic_vector (3 downto 0);
  61. HEX3, HEX2, HEX1, HEX0: out std_logic_vector (0 to 6) -- 0 to 6 !!
  62. );
  63. end entity DemoSSD;
  64.  
  65. architecture DemoSSD1 of DemoSSD is
  66.  
  67. component hex7seg IS
  68. PORT (
  69. hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  70. display : OUT STD_LOGIC_VECTOR(0 TO 6)
  71. );
  72. end component hex7seg;
  73.  
  74. signal num3, num2, num1 : std_logic_vector(3 downto 0);
  75.  
  76. begin
  77. LEDR <= SW;
  78. LEDG <= not KEY;
  79.  
  80. num3 <= "0011"; -- waarde 3
  81. num2 <= "0010"; -- waarde 2
  82. num1 <= "0001"; -- waarde 1
  83.  
  84. h3: hex7seg port map(num3, HEX3);
  85. h2: hex7seg port map(num2, HEX2);
  86. h1: hex7seg port map(num1, HEX1);
  87. h0: hex7seg port map(SW(3 downto 0), HEX0);
  88.  
  89. end DemoSSD1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement