Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.15 KB | None | 0 0
  1. -- Company: Kennesaw State University
  2. -- Engineer: Anthony Bell
  3. -- Create Date: 02/18/2017 09:44:43 PM
  4. -- Design Name: Stop Watch
  5. -- Module Name: LAB3 - Behavioral
  6. -- Project Name: project_3
  7. -- Description: counts from 0 to 20 and displays victory pattern on leds
  8. -- Revision: 1st revision
  9. ---------------------------------------------------------------------
  10. library IEEE;
  11. use IEEE.STD_LOGIC_1164.ALL;
  12. use IEEE.NUMERIC_STD.all;
  13.  
  14.  
  15. entity lab_3 is
  16. Port (
  17. -------------led output-------------------------------------
  18. led: out std_logic_vector(15 downto 0);
  19. -------------button inputs----------------------------------
  20. btnc: in std_logic;
  21. btnd: in std_logic;
  22. -----------7 seg outpus--------------------------------------------
  23. seg: out std_logic_vector(6 downto 0); --MSB=a: LSB=g
  24. -------------7 seg enables----------------------------------------
  25. an: out std_logic_vector(3 downto 0)
  26.  
  27. );
  28.  
  29. end lab_3;
  30.  
  31. architecture Behavioral of lab_3 is
  32.  
  33. ------decimal seven segment display--------------------------CONSTANTS
  34. constant ZERO_7SEG: std_logic_vector(6 downto 0) := "1000000";
  35. constant ONE_7SEG: std_logic_vector(6 downto 0) := "1111001";
  36. constant TWO_7SEG: std_logic_vector(6 downto 0) := "0100100";
  37. constant THREE_7SEG: std_logic_vector(6 downto 0) := "0110000";
  38. constant FOUR_7SEG: std_logic_vector(6 downto 0) := "0011001";
  39. constant FIVE_7SEG: std_logic_vector(6 downto 0) := "0010010";
  40. constant SIX_7SEG: std_logic_vector(6 downto 0) := "0000010";
  41. constant SEVEN_7SEG: std_logic_vector(6 downto 0) := "1111000";
  42. constant EIGHT_7SEG: std_logic_vector(6 downto 0) := "0000000";
  43. constant NINE_7SEG: std_logic_vector(6 downto 0) := "0010000";
  44. constant TEN_7SEG: std_logic_vector(6 downto 0) := "1000000";
  45. constant ELEVEN_7SEG: std_logic_vector(6 downto 0) := "1111001";
  46. constant TWELVE_7SEG: std_logic_vector(6 downto 0) := "0100100";
  47. constant THIRTEEN_7SEG: std_logic_vector(6 downto 0) := "0110000";
  48. constant FOURTEEN_7SEG: std_logic_vector(6 downto 0) := "0110001";
  49. constant FIFTEEN_7SEG: std_logic_vector(6 downto 0) := "0010010";
  50. constant SIXTEEN_7SEG: std_logic_vector(6 downto 0) := "0000010";
  51. constant SEVENTEEN_7SEG: std_logic_vector(6 downto 0) := "1111000";
  52. constant EIGHTEEN_7SEG: std_logic_vector(6 downto 0) := "0000000";
  53. constant NINETEEN_7SEG: std_logic_vector(6 downto 0) := "0010000";
  54. constant TWENTY_7SEG: std_logic_vector(6 downto 0) := "1111001";
  55.  
  56. -------------------led dance-------------------------------------- ` constant step_one: std_logic_vector(15 downto 0):="0000000000000001";`
  57. constant step_two: std_logic_vector(15 downto 0):="0000000000000010";
  58. constant step_three: std_logic_vector(15 downto 0):="0000000000000100";
  59. constant step_four: std_logic_vector(15 downto 0):="0000000000001000";
  60. constant step_five: std_logic_vector(15 downto 0):="0000000000010000";
  61. constant step_six: std_logic_vector(15 downto 0) :="0000000000100000";
  62. constant step_seven: std_logic_vector(15 downto 0) :="0000000001000000";
  63. constant step_eight: std_logic_vector(15 downto 0) :="0000000010000000";
  64. constant step_nine: std_logic_vector(15 downto 0) :="0000000100000000";
  65. constant step_ten: std_logic_vector(15 downto 0) :="0000001000000000";
  66. constant step_eleven: std_logic_vector(15 downto 0):="0000010000000000";
  67. constant step_twelve: std_logic_vector(15 downto 0):="0000100000000000";
  68. constant step_thirteen: std_logic_vector(15 downto 0):="0001000000000000";
  69. constant step_fourteen: std_logic_vector(15 downto 0) :="0010000000000000";
  70. constant step_fifteen: std_logic_vector(15 downto 0) :="0100000000000000";
  71. constant step_sixteen: std_logic_vector(15 downto 0):="1000000000000000";
  72.  
  73. ---------------------active constants-----------------------------------
  74. constant active: std_logic :='1';
  75. constant inactive: std_logic :='0';
  76. constant ACTIVE_RESET: std_logic := '0';
  77. constant TERMINAL_VALUE: integer := 50000000;
  78. -------------------internal connections-------------------------SIGNALS
  79.  
  80. signal Clock: std_logic;
  81. signal Count: unsigned(7 downto 0);
  82. signal DividedClock: std_logic;
  83. signal Digit0: std_logic_vector(6 downto 0);
  84. signal Digit1: std_logic_vector(6 downto 0);
  85. signal DigitSelect: std_logic;
  86. signal led_dance: std_logic_vector( 15 downto 0);
  87.  
  88. -----------------clock divider----------------------------
  89. begin
  90.  
  91. process(Clock)
  92. variable counter: integer range 0 to TERMINAL_VALUE;
  93. begin
  94. if (btnD=ACTIVE_RESET) then
  95. counter := 0;
  96. elsif (rising_edge(Clock)) then
  97. counter := counter + 1;
  98. if (counter = TERMINAL_VALUE) then
  99. counter := 0;
  100. DividedClock <= not DividedClock;
  101. end if;
  102. end if;
  103. end process;
  104.  
  105. --------------------------counter-----------------------------
  106. process(Clock)
  107.  
  108. begin
  109. if (btnD=active) then
  110. count <= "00000000";
  111.  
  112. elsif (rising_edge(Clock)) then
  113. count <= count + 1;
  114.  
  115. end if;
  116. end process;
  117.  
  118. -------------------BCD to 7seg--------------------------------
  119.  
  120. with count select
  121. Digit0 <= ZERO_7SEG when "0000000",
  122. ONE_7SEG when "0000001",
  123. TWO_7SEG when "0000010",
  124. THREE_7SEG when "0000011",
  125. FOUR_7SEG when "0000100",
  126. FIVE_7SEG when "0000101",
  127. SIX_7SEG when "0000110",
  128. SEVEN_7SEG when "0000111",
  129. EIGHT_7SEG when "0001000",
  130. NINE_7SEG when "0001001",
  131. TEN_7SEG when "0001010",
  132. ELEVEN_7SEG when "0001011",
  133. TWELVE_7SEG when "0001100",
  134. THIRTEEN_7SEG when "0001101",
  135. FOURTEEN_7SEG when "0001110",
  136. FIFTEEN_7SEG when "0001111",
  137. SIXTEEN_7SEG when "0010000",
  138. SEVENTEEN_7SEG when "0010001",
  139. EIGHTEEN_7SEG when "0010010",
  140. NINETEEN_7SEG when "0010011",
  141. TWENTY_7SEG when others;
  142.  
  143. with count select
  144. Digit1 <= ZERO_7SEG when "0000000",
  145. ZERO_7SEG when "0000001",
  146. ZERO_7SEG when "0000010",
  147. ZERO_7SEG when "0000011",
  148. ZERO_7SEG when "0000100",
  149. ZERO_7SEG when "0000101",
  150. ZERO_7SEG when "0000110",
  151. ZERO_7SEG when "0000111",
  152. ZERO_7SEG when "0001000",
  153. ZERO_7SEG when "0001001",
  154. TWO_7SEG when "0010100",
  155. ONE_7SEG when others;
  156.  
  157. -------------------Multipliexer----------------------------------------
  158.  
  159. -- with Digit0 select
  160. -- an <="1110" when others;
  161.  
  162. -- with Digit1 select
  163. -- an<="1101" when "0001010";
  164.  
  165. -------------------7 seg victory dance---------------------------------
  166.  
  167. -- with count select
  168. -- led_dance<= step_one +1 when "0010100",
  169.  
  170. ------------------Digit Select clock-----------------------------------
  171.  
  172. --STATE_REGISTER: process(count, Clock)
  173. -- begin
  174. -- if (count = ACTIVE) then
  175. -- DigitSelect <= BLANK;
  176. -- elsif (rising_edge(gameClock)) then
  177. -- CurrentState <= NextState;
  178. -- end if;
  179. -- end process;
  180. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement