Advertisement
Guest User

Untitled

a guest
Nov 27th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.56 KB | None | 0 0
  1. -- "Simple" programming project done in VHDL to throw onto a DE-10 board.
  2. -- A programmable timer/alarm clock and a stopwatch. Use switches and buttons on the board to
  3. -- Program the alarm clock, or switch between modes.
  4.  
  5. LIBRARY ieee;
  6. USE ieee.std_logic_1164.all;
  7. USE ieee.numeric_std.all;
  8.  
  9. ENTITY GroupClockTest IS
  10. PORT( CLOCK, RESETN : IN STD_LOGIC;
  11. CE, UDN : IN STD_LOGIC;
  12. START : IN STD_LOGIC;
  13. ADDSEC, ADDMIN, ADDHR : IN STD_LOGIC;
  14. HEX54, HEX32, HEX10 : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
  15. LED : OUT STD_LOGIC;
  16. BUZZ : OUT STD_LOGIC);
  17. -- CE = Switch between modes, 0 = CountClock, 1 = Stopwatch
  18. -- ADDSEC, etc are the pushbuttons related to adding time
  19. -- HEX54, etc are outputs to 7-segment display
  20. -- LED + BUZZ are an LED and buzzer on DE-10
  21. END GroupClockTest;
  22.  
  23. ARCHITECTURE behavior OF GroupClockTest IS
  24. SIGNAL COUNTSEC : INTEGER := 1;
  25. SIGNAL SEC_CLOCK : STD_LOGIC := '0';
  26. SIGNAL HOURS : INTEGER range 0 to 59;
  27. SIGNAL SECS : INTEGER range 0 to 59;
  28. SIGNAL MINS : INTEGER range 0 to 59;
  29. -- COUNTSEC + SEC_CLOCK are used for scaling down DE-10 50hz clock to 1sec
  30. -- HOURS,SECS,MINS are values for time
  31.  
  32. BEGIN
  33. PROCESS(CLOCK, RESETN)
  34. BEGIN
  35. IF (RESETN = '0') THEN -- Clock scaling for seconds
  36. COUNTSEC <= 1;
  37. ELSIF (RISING_EDGE(CLOCK)) THEN
  38. COUNTSEC <= COUNTSEC + 1;
  39. IF (COUNTSEC = 25000000) THEN
  40. SEC_CLOCK <= NOT (SEC_CLOCK);
  41. COUNTSEC <= 1;
  42. END IF;
  43. END IF; -- End clock scaling
  44.  
  45. IF RISING_EDGE(SEC_CLOCK) THEN
  46. IF CE = '0' THEN -- Alarm Clock / Timer BEGIN
  47. IF RESETN = '0' THEN -- Universal Reset
  48. HOURS <= 0;
  49. SECS <= 0;
  50. MINS <= 0;
  51. END IF;
  52.  
  53. IF ADDHR = '0' THEN -- If button ADDHR pushed, add/sub time
  54. IF UDN = '0' THEN
  55. HOURS <= HOURS + 1;
  56. ELSIF UDN = '1' THEN
  57. HOURS <= HOURS - 1;
  58. END IF;
  59. END IF;
  60. IF ADDSEC = '0' THEN -- Adding time SECS
  61. IF UDN = '0' THEN
  62. SECS <= SECS + 1;
  63. ELSIF UDN = '1' THEN
  64. SECS <= SECS - 1;
  65. END IF;
  66. END IF;
  67. IF ADDMIN = '0' THEN -- Adding time MINS
  68. IF UDN = '0' THEN
  69. MINS <= MINS + 1;
  70. ELSIF UDN = '1' THEN
  71. MINS <= MINS - 1;
  72. END IF;
  73. END IF;
  74.  
  75. IF START = '1' THEN -- START timer after time has been set
  76. IF MINS = 0 THEN
  77. HOURS <= HOURS - 1;
  78. MINS <= 59;
  79. END IF;
  80. IF SECS = 0 THEN
  81. MINS <= MINS - 1;
  82. SECS <= 59;
  83. END IF;
  84. IF (HOURS = 0 AND MINS = 0 AND SECS = 0) THEN
  85. LED <= '1';
  86. BUZZ <= '1';
  87. -- If time = 0, buzzer + LED
  88. END IF;
  89. END IF;
  90. END IF; -- Alarm Clock / Timer END
  91.  
  92. ELSIF CE = '1' THEN -- Stopwatch BEGIN
  93. IF RESETN = '0' THEN -- Reset Again
  94. HOURS <= 0;
  95. SECS <= 0;
  96. MINS <= 0;
  97. END IF;
  98.  
  99. IF HOURS = 59 THEN
  100. HOURS <= 0;
  101. END IF;
  102. IF SECS = 59 THEN
  103. SECS <= 0;
  104. MINS <= MINS + 1;
  105. END IF;
  106. IF MINS = 59 THEN
  107. MINS <= 0;
  108. HOURS <= HOURS + 1;
  109. END IF;
  110. END IF; -- Stopwatch END
  111. END PROCESS;
  112.  
  113. -- Seven Segment Display Output Section
  114. HEX10 <= "10000001000000" WHEN SECS = 0;
  115. HEX10 <= "10000001111001" WHEN SECS = 1;
  116. HEX10 <= "10000000100100" WHEN SECS = 2;
  117. HEX10 <= "10000000110000" WHEN SECS = 3;
  118. HEX10 <= "10000000011001" WHEN SECS = 4;
  119. HEX10 <= "10000000010010" WHEN SECS = 5;
  120. HEX10 <= "10000000000010" WHEN SECS = 6;
  121. HEX10 <= "10000001111000" WHEN SECS = 7;
  122. HEX10 <= "10000000000000" WHEN SECS = 8;
  123. HEX10 <= "10000000010000" WHEN SECS = 9;
  124. HEX10 <= "11110011000000" WHEN SECS = 10;
  125. HEX10 <= "11110011111001" WHEN SECS = 11;
  126. HEX10 <= "11110010100100" WHEN SECS = 12;
  127. HEX10 <= "11110010110000" WHEN SECS = 13;
  128. HEX10 <= "11110010011001" WHEN SECS = 14;
  129. HEX10 <= "11110010010010" WHEN SECS = 15;
  130. HEX10 <= "11110010000010" WHEN SECS = 16;
  131. HEX10 <= "11110011111000" WHEN SECS = 17;
  132. HEX10 <= "11110010000000" WHEN SECS = 18;
  133. HEX10 <= "11110010010000" WHEN SECS = 19;
  134. HEX10 <= "01001001000000" WHEN SECS = 20;
  135. HEX10 <= "01001001111001" WHEN SECS = 21;
  136. HEX10 <= "01001000100100" WHEN SECS = 22;
  137. HEX10 <= "01001000110000" WHEN SECS = 23;
  138. HEX10 <= "01001000011001" WHEN SECS = 24;
  139. HEX10 <= "01001000010010" WHEN SECS = 25;
  140. HEX10 <= "01001000000010" WHEN SECS = 26;
  141. HEX10 <= "01001001111000" WHEN SECS = 27;
  142. HEX10 <= "01001000000000" WHEN SECS = 28;
  143. HEX10 <= "01001000010000" WHEN SECS = 29;
  144. HEX10 <= "01100001000000" WHEN SECS = 30;
  145. HEX10 <= "01100001111001" WHEN SECS = 31;
  146. HEX10 <= "01100000100100" WHEN SECS = 32;
  147. HEX10 <= "01100000110000" WHEN SECS = 33;
  148. HEX10 <= "01100000011001" WHEN SECS = 34;
  149. HEX10 <= "01100000010010" WHEN SECS = 35;
  150. HEX10 <= "01100000000010" WHEN SECS = 36;
  151. HEX10 <= "01100001111000" WHEN SECS = 37;
  152. HEX10 <= "01100000000000" WHEN SECS = 38;
  153. HEX10 <= "01100000010000" WHEN SECS = 39;
  154. HEX10 <= "00110011000000" WHEN SECS = 40;
  155. HEX10 <= "00110011111001" WHEN SECS = 41;
  156. HEX10 <= "00110010100100" WHEN SECS = 42;
  157. HEX10 <= "00110010110000" WHEN SECS = 43;
  158. HEX10 <= "00110010011001" WHEN SECS = 44;
  159. HEX10 <= "00110010010010" WHEN SECS = 45;
  160. HEX10 <= "00110010000010" WHEN SECS = 46;
  161. HEX10 <= "00110011111000" WHEN SECS = 47;
  162. HEX10 <= "00110010000000" WHEN SECS = 48;
  163. HEX10 <= "00110010010000" WHEN SECS = 49;
  164. HEX10 <= "00100101000000" WHEN SECS = 50;
  165. HEX10 <= "00100101111001" WHEN SECS = 51;
  166. HEX10 <= "00100100100100" WHEN SECS = 52;
  167. HEX10 <= "00100100110000" WHEN SECS = 53;
  168. HEX10 <= "00100100011001" WHEN SECS = 54;
  169. HEX10 <= "00100100010010" WHEN SECS = 55;
  170. HEX10 <= "00100100000010" WHEN SECS = 56;
  171. HEX10 <= "00100101111000" WHEN SECS = 57;
  172. HEX10 <= "00100100000000" WHEN SECS = 58;
  173. HEX10 <= "00100100010000" WHEN SECS = 59;
  174.  
  175. HEX32 <= "10000001000000" WHEN MINS = 0;
  176. HEX32 <= "10000001111001" WHEN MINS = 1;
  177. HEX32 <= "10000000100100" WHEN MINS = 2;
  178. HEX32 <= "10000000110000" WHEN MINS = 3;
  179. HEX32 <= "10000000011001" WHEN MINS = 4;
  180. HEX32 <= "10000000010010" WHEN MINS = 5;
  181. HEX32 <= "10000000000010" WHEN MINS = 6;
  182. HEX32 <= "10000001111000" WHEN MINS = 7;
  183. HEX32 <= "10000000000000" WHEN MINS = 8;
  184. HEX32 <= "10000000010000" WHEN MINS = 9;
  185. HEX32 <= "11110011000000" WHEN MINS = 10;
  186. HEX32 <= "11110011111001" WHEN MINS = 11;
  187. HEX32 <= "11110010100100" WHEN MINS = 12;
  188. HEX32 <= "11110010110000" WHEN MINS = 13;
  189. HEX32 <= "11110010011001" WHEN MINS = 14;
  190. HEX32 <= "11110010010010" WHEN MINS = 15;
  191. HEX32 <= "11110010000010" WHEN MINS = 16;
  192. HEX32 <= "11110011111000" WHEN MINS = 17;
  193. HEX32 <= "11110010000000" WHEN MINS = 18;
  194. HEX32 <= "11110010010000" WHEN MINS = 19;
  195. HEX32 <= "01001001000000" WHEN MINS = 20;
  196. HEX32 <= "01001001111001" WHEN MINS = 21;
  197. HEX32 <= "01001000100100" WHEN MINS = 22;
  198. HEX32 <= "01001000110000" WHEN MINS = 23;
  199. HEX32 <= "01001000011001" WHEN MINS = 24;
  200. HEX32 <= "01001000010010" WHEN MINS = 25;
  201. HEX32 <= "01001000000010" WHEN MINS = 26;
  202. HEX32 <= "01001001111000" WHEN MINS = 27;
  203. HEX32 <= "01001000000000" WHEN MINS = 28;
  204. HEX32 <= "01001000010000" WHEN MINS = 29;
  205. HEX32 <= "01100001000000" WHEN MINS = 30;
  206. HEX32 <= "01100001111001" WHEN MINS = 31;
  207. HEX32 <= "01100000100100" WHEN MINS = 32;
  208. HEX32 <= "01100000110000" WHEN MINS = 33;
  209. HEX32 <= "01100000011001" WHEN MINS = 34;
  210. HEX32 <= "01100000010010" WHEN MINS = 35;
  211. HEX32 <= "01100000000010" WHEN MINS = 36;
  212. HEX32 <= "01100001111000" WHEN MINS = 37;
  213. HEX32 <= "01100000000000" WHEN MINS = 38;
  214. HEX32 <= "01100000010000" WHEN MINS = 39;
  215. HEX32 <= "00110011000000" WHEN MINS = 40;
  216. HEX32 <= "00110011111001" WHEN MINS = 41;
  217. HEX32 <= "00110010100100" WHEN MINS = 42;
  218. HEX32 <= "00110010110000" WHEN MINS = 43;
  219. HEX32 <= "00110010011001" WHEN MINS = 44;
  220. HEX32 <= "00110010010010" WHEN MINS = 45;
  221. HEX32 <= "00110010000010" WHEN MINS = 46;
  222. HEX32 <= "00110011111000" WHEN MINS = 47;
  223. HEX32 <= "00110010000000" WHEN MINS = 48;
  224. HEX32 <= "00110010010000" WHEN MINS = 49;
  225. HEX32 <= "00100101000000" WHEN MINS = 50;
  226. HEX32 <= "00100101111001" WHEN MINS = 51;
  227. HEX32 <= "00100100100100" WHEN MINS = 52;
  228. HEX32 <= "00100100110000" WHEN MINS = 53;
  229. HEX32 <= "00100100011001" WHEN MINS = 54;
  230. HEX32 <= "00100100010010" WHEN MINS = 55;
  231. HEX32 <= "00100100000010" WHEN MINS = 56;
  232. HEX32 <= "00100101111000" WHEN MINS = 57;
  233. HEX32 <= "00100100000000" WHEN MINS = 58;
  234. HEX32 <= "00100100010000" WHEN MINS = 59;
  235.  
  236. HEX54 <= "10000001000000" WHEN SECS = 0;
  237. HEX54 <= "10000001111001" WHEN SECS = 1;
  238. HEX54 <= "10000000100100" WHEN SECS = 2;
  239. HEX54 <= "10000000110000" WHEN SECS = 3;
  240. HEX54 <= "10000000011001" WHEN SECS = 4;
  241. HEX54 <= "10000000010010" WHEN SECS = 5;
  242. HEX54 <= "10000000000010" WHEN SECS = 6;
  243. HEX54 <= "10000001111000" WHEN SECS = 7;
  244. HEX54 <= "10000000000000" WHEN SECS = 8;
  245. HEX54 <= "10000000010000" WHEN SECS = 9;
  246. HEX54 <= "11110011000000" WHEN SECS = 10;
  247. HEX54 <= "11110011111001" WHEN SECS = 11;
  248. HEX54 <= "11110010100100" WHEN SECS = 12;
  249. HEX54 <= "11110010110000" WHEN SECS = 13;
  250. HEX54 <= "11110010011001" WHEN SECS = 14;
  251. HEX54 <= "11110010010010" WHEN SECS = 15;
  252. HEX54 <= "11110010000010" WHEN SECS = 16;
  253. HEX54 <= "11110011111000" WHEN SECS = 17;
  254. HEX54 <= "11110010000000" WHEN SECS = 18;
  255. HEX54 <= "11110010010000" WHEN SECS = 19;
  256. HEX54 <= "01001001000000" WHEN SECS = 20;
  257. HEX54 <= "01001001111001" WHEN SECS = 21;
  258. HEX54 <= "01001000100100" WHEN SECS = 22;
  259. HEX54 <= "01001000110000" WHEN SECS = 23;
  260. HEX54 <= "01001000011001" WHEN SECS = 24;
  261. HEX54 <= "01001000010010" WHEN SECS = 25;
  262. HEX54 <= "01001000000010" WHEN SECS = 26;
  263. HEX54 <= "01001001111000" WHEN SECS = 27;
  264. HEX54 <= "01001000000000" WHEN SECS = 28;
  265. HEX54 <= "01001000010000" WHEN SECS = 29;
  266. HEX54 <= "01100001000000" WHEN SECS = 30;
  267. HEX54 <= "01100001111001" WHEN SECS = 31;
  268. HEX54 <= "01100000100100" WHEN SECS = 32;
  269. HEX54 <= "01100000110000" WHEN SECS = 33;
  270. HEX54 <= "01100000011001" WHEN SECS = 34;
  271. HEX54 <= "01100000010010" WHEN SECS = 35;
  272. HEX54 <= "01100000000010" WHEN SECS = 36;
  273. HEX54 <= "01100001111000" WHEN SECS = 37;
  274. HEX54 <= "01100000000000" WHEN SECS = 38;
  275. HEX54 <= "01100000010000" WHEN SECS = 39;
  276. HEX54 <= "00110011000000" WHEN SECS = 40;
  277. HEX54 <= "00110011111001" WHEN SECS = 41;
  278. HEX54 <= "00110010100100" WHEN SECS = 42;
  279. HEX54 <= "00110010110000" WHEN SECS = 43;
  280. HEX54 <= "00110010011001" WHEN SECS = 44;
  281. HEX54 <= "00110010010010" WHEN SECS = 45;
  282. HEX54 <= "00110010000010" WHEN SECS = 46;
  283. HEX54 <= "00110011111000" WHEN SECS = 47;
  284. HEX54 <= "00110010000000" WHEN SECS = 48;
  285. HEX54 <= "00110010010000" WHEN SECS = 49;
  286. HEX54 <= "00100101000000" WHEN SECS = 50;
  287. HEX54 <= "00100101111001" WHEN SECS = 51;
  288. HEX54 <= "00100100100100" WHEN SECS = 52;
  289. HEX54 <= "00100100110000" WHEN SECS = 53;
  290. HEX54 <= "00100100011001" WHEN SECS = 54;
  291. HEX54 <= "00100100010010" WHEN SECS = 55;
  292. HEX54 <= "00100100000010" WHEN SECS = 56;
  293. HEX54 <= "00100101111000" WHEN SECS = 57;
  294. HEX54 <= "00100100000000" WHEN SECS = 58;
  295. HEX54 <= "00100100010000" WHEN SECS = 59;
  296.  
  297. END behavior;
  298.  
  299.  
  300.  
  301.  
  302. Output Errors:
  303.  
  304.  
  305. Error (10818): Can't infer register for "MINS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  306. Info (10041): Inferred latch for "MINS[0]" at GroupClockTest.vhd(33)
  307. Error (10818): Can't infer register for "MINS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  308. Info (10041): Inferred latch for "MINS[1]" at GroupClockTest.vhd(33)
  309. Error (10818): Can't infer register for "MINS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  310. Info (10041): Inferred latch for "MINS[2]" at GroupClockTest.vhd(33)
  311. Error (10818): Can't infer register for "MINS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  312. Info (10041): Inferred latch for "MINS[3]" at GroupClockTest.vhd(33)
  313. Error (10818): Can't infer register for "MINS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  314. Info (10041): Inferred latch for "MINS[4]" at GroupClockTest.vhd(33)
  315. Error (10818): Can't infer register for "MINS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  316. Info (10041): Inferred latch for "MINS[5]" at GroupClockTest.vhd(33)
  317. Error (10818): Can't infer register for "SECS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  318. Info (10041): Inferred latch for "SECS[0]" at GroupClockTest.vhd(33)
  319. Error (10818): Can't infer register for "SECS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  320. Info (10041): Inferred latch for "SECS[1]" at GroupClockTest.vhd(33)
  321. Error (10818): Can't infer register for "SECS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  322. Info (10041): Inferred latch for "SECS[2]" at GroupClockTest.vhd(33)
  323. Error (10818): Can't infer register for "SECS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  324. Info (10041): Inferred latch for "SECS[3]" at GroupClockTest.vhd(33)
  325. Error (10818): Can't infer register for "SECS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  326. Info (10041): Inferred latch for "SECS[4]" at GroupClockTest.vhd(33)
  327. Error (10818): Can't infer register for "SECS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  328. Info (10041): Inferred latch for "SECS[5]" at GroupClockTest.vhd(33)
  329. Error (10818): Can't infer register for "HOURS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  330. Info (10041): Inferred latch for "HOURS[0]" at GroupClockTest.vhd(33)
  331. Error (10818): Can't infer register for "HOURS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  332. Info (10041): Inferred latch for "HOURS[1]" at GroupClockTest.vhd(33)
  333. Error (10818): Can't infer register for "HOURS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  334. Info (10041): Inferred latch for "HOURS[2]" at GroupClockTest.vhd(33)
  335. Error (10818): Can't infer register for "HOURS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  336. Info (10041): Inferred latch for "HOURS[3]" at GroupClockTest.vhd(33)
  337. Error (10818): Can't infer register for "HOURS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  338. Info (10041): Inferred latch for "HOURS[4]" at GroupClockTest.vhd(33)
  339. Error (10818): Can't infer register for "HOURS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
  340. Info (10041): Inferred latch for "HOURS[5]" at GroupClockTest.vhd(33)
  341. Error (10822): HDL error at GroupClockTest.vhd(45): couldn't implement registers for assignments on this clock edge
  342. Error (12153): Can't elaborate top-level user hierarchy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement