Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- "Simple" programming project done in VHDL to throw onto a DE-10 board.
- -- A programmable timer/alarm clock and a stopwatch. Use switches and buttons on the board to
- -- Program the alarm clock, or switch between modes.
- LIBRARY ieee;
- USE ieee.std_logic_1164.all;
- USE ieee.numeric_std.all;
- ENTITY GroupClockTest IS
- PORT( CLOCK, RESETN : IN STD_LOGIC;
- CE, UDN : IN STD_LOGIC;
- START : IN STD_LOGIC;
- ADDSEC, ADDMIN, ADDHR : IN STD_LOGIC;
- HEX54, HEX32, HEX10 : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
- LED : OUT STD_LOGIC;
- BUZZ : OUT STD_LOGIC);
- -- CE = Switch between modes, 0 = CountClock, 1 = Stopwatch
- -- ADDSEC, etc are the pushbuttons related to adding time
- -- HEX54, etc are outputs to 7-segment display
- -- LED + BUZZ are an LED and buzzer on DE-10
- END GroupClockTest;
- ARCHITECTURE behavior OF GroupClockTest IS
- SIGNAL COUNTSEC : INTEGER := 1;
- SIGNAL SEC_CLOCK : STD_LOGIC := '0';
- SIGNAL HOURS : INTEGER range 0 to 59;
- SIGNAL SECS : INTEGER range 0 to 59;
- SIGNAL MINS : INTEGER range 0 to 59;
- -- COUNTSEC + SEC_CLOCK are used for scaling down DE-10 50hz clock to 1sec
- -- HOURS,SECS,MINS are values for time
- BEGIN
- PROCESS(CLOCK, RESETN)
- BEGIN
- IF (RESETN = '0') THEN -- Clock scaling for seconds
- COUNTSEC <= 1;
- ELSIF (RISING_EDGE(CLOCK)) THEN
- COUNTSEC <= COUNTSEC + 1;
- IF (COUNTSEC = 25000000) THEN
- SEC_CLOCK <= NOT (SEC_CLOCK);
- COUNTSEC <= 1;
- END IF;
- END IF; -- End clock scaling
- IF RISING_EDGE(SEC_CLOCK) THEN
- IF CE = '0' THEN -- Alarm Clock / Timer BEGIN
- IF RESETN = '0' THEN -- Universal Reset
- HOURS <= 0;
- SECS <= 0;
- MINS <= 0;
- END IF;
- IF ADDHR = '0' THEN -- If button ADDHR pushed, add/sub time
- IF UDN = '0' THEN
- HOURS <= HOURS + 1;
- ELSIF UDN = '1' THEN
- HOURS <= HOURS - 1;
- END IF;
- END IF;
- IF ADDSEC = '0' THEN -- Adding time SECS
- IF UDN = '0' THEN
- SECS <= SECS + 1;
- ELSIF UDN = '1' THEN
- SECS <= SECS - 1;
- END IF;
- END IF;
- IF ADDMIN = '0' THEN -- Adding time MINS
- IF UDN = '0' THEN
- MINS <= MINS + 1;
- ELSIF UDN = '1' THEN
- MINS <= MINS - 1;
- END IF;
- END IF;
- IF START = '1' THEN -- START timer after time has been set
- IF MINS = 0 THEN
- HOURS <= HOURS - 1;
- MINS <= 59;
- END IF;
- IF SECS = 0 THEN
- MINS <= MINS - 1;
- SECS <= 59;
- END IF;
- IF (HOURS = 0 AND MINS = 0 AND SECS = 0) THEN
- LED <= '1';
- BUZZ <= '1';
- -- If time = 0, buzzer + LED
- END IF;
- END IF;
- END IF; -- Alarm Clock / Timer END
- ELSIF CE = '1' THEN -- Stopwatch BEGIN
- IF RESETN = '0' THEN -- Reset Again
- HOURS <= 0;
- SECS <= 0;
- MINS <= 0;
- END IF;
- IF HOURS = 59 THEN
- HOURS <= 0;
- END IF;
- IF SECS = 59 THEN
- SECS <= 0;
- MINS <= MINS + 1;
- END IF;
- IF MINS = 59 THEN
- MINS <= 0;
- HOURS <= HOURS + 1;
- END IF;
- END IF; -- Stopwatch END
- END PROCESS;
- -- Seven Segment Display Output Section
- HEX10 <= "10000001000000" WHEN SECS = 0;
- HEX10 <= "10000001111001" WHEN SECS = 1;
- HEX10 <= "10000000100100" WHEN SECS = 2;
- HEX10 <= "10000000110000" WHEN SECS = 3;
- HEX10 <= "10000000011001" WHEN SECS = 4;
- HEX10 <= "10000000010010" WHEN SECS = 5;
- HEX10 <= "10000000000010" WHEN SECS = 6;
- HEX10 <= "10000001111000" WHEN SECS = 7;
- HEX10 <= "10000000000000" WHEN SECS = 8;
- HEX10 <= "10000000010000" WHEN SECS = 9;
- HEX10 <= "11110011000000" WHEN SECS = 10;
- HEX10 <= "11110011111001" WHEN SECS = 11;
- HEX10 <= "11110010100100" WHEN SECS = 12;
- HEX10 <= "11110010110000" WHEN SECS = 13;
- HEX10 <= "11110010011001" WHEN SECS = 14;
- HEX10 <= "11110010010010" WHEN SECS = 15;
- HEX10 <= "11110010000010" WHEN SECS = 16;
- HEX10 <= "11110011111000" WHEN SECS = 17;
- HEX10 <= "11110010000000" WHEN SECS = 18;
- HEX10 <= "11110010010000" WHEN SECS = 19;
- HEX10 <= "01001001000000" WHEN SECS = 20;
- HEX10 <= "01001001111001" WHEN SECS = 21;
- HEX10 <= "01001000100100" WHEN SECS = 22;
- HEX10 <= "01001000110000" WHEN SECS = 23;
- HEX10 <= "01001000011001" WHEN SECS = 24;
- HEX10 <= "01001000010010" WHEN SECS = 25;
- HEX10 <= "01001000000010" WHEN SECS = 26;
- HEX10 <= "01001001111000" WHEN SECS = 27;
- HEX10 <= "01001000000000" WHEN SECS = 28;
- HEX10 <= "01001000010000" WHEN SECS = 29;
- HEX10 <= "01100001000000" WHEN SECS = 30;
- HEX10 <= "01100001111001" WHEN SECS = 31;
- HEX10 <= "01100000100100" WHEN SECS = 32;
- HEX10 <= "01100000110000" WHEN SECS = 33;
- HEX10 <= "01100000011001" WHEN SECS = 34;
- HEX10 <= "01100000010010" WHEN SECS = 35;
- HEX10 <= "01100000000010" WHEN SECS = 36;
- HEX10 <= "01100001111000" WHEN SECS = 37;
- HEX10 <= "01100000000000" WHEN SECS = 38;
- HEX10 <= "01100000010000" WHEN SECS = 39;
- HEX10 <= "00110011000000" WHEN SECS = 40;
- HEX10 <= "00110011111001" WHEN SECS = 41;
- HEX10 <= "00110010100100" WHEN SECS = 42;
- HEX10 <= "00110010110000" WHEN SECS = 43;
- HEX10 <= "00110010011001" WHEN SECS = 44;
- HEX10 <= "00110010010010" WHEN SECS = 45;
- HEX10 <= "00110010000010" WHEN SECS = 46;
- HEX10 <= "00110011111000" WHEN SECS = 47;
- HEX10 <= "00110010000000" WHEN SECS = 48;
- HEX10 <= "00110010010000" WHEN SECS = 49;
- HEX10 <= "00100101000000" WHEN SECS = 50;
- HEX10 <= "00100101111001" WHEN SECS = 51;
- HEX10 <= "00100100100100" WHEN SECS = 52;
- HEX10 <= "00100100110000" WHEN SECS = 53;
- HEX10 <= "00100100011001" WHEN SECS = 54;
- HEX10 <= "00100100010010" WHEN SECS = 55;
- HEX10 <= "00100100000010" WHEN SECS = 56;
- HEX10 <= "00100101111000" WHEN SECS = 57;
- HEX10 <= "00100100000000" WHEN SECS = 58;
- HEX10 <= "00100100010000" WHEN SECS = 59;
- HEX32 <= "10000001000000" WHEN MINS = 0;
- HEX32 <= "10000001111001" WHEN MINS = 1;
- HEX32 <= "10000000100100" WHEN MINS = 2;
- HEX32 <= "10000000110000" WHEN MINS = 3;
- HEX32 <= "10000000011001" WHEN MINS = 4;
- HEX32 <= "10000000010010" WHEN MINS = 5;
- HEX32 <= "10000000000010" WHEN MINS = 6;
- HEX32 <= "10000001111000" WHEN MINS = 7;
- HEX32 <= "10000000000000" WHEN MINS = 8;
- HEX32 <= "10000000010000" WHEN MINS = 9;
- HEX32 <= "11110011000000" WHEN MINS = 10;
- HEX32 <= "11110011111001" WHEN MINS = 11;
- HEX32 <= "11110010100100" WHEN MINS = 12;
- HEX32 <= "11110010110000" WHEN MINS = 13;
- HEX32 <= "11110010011001" WHEN MINS = 14;
- HEX32 <= "11110010010010" WHEN MINS = 15;
- HEX32 <= "11110010000010" WHEN MINS = 16;
- HEX32 <= "11110011111000" WHEN MINS = 17;
- HEX32 <= "11110010000000" WHEN MINS = 18;
- HEX32 <= "11110010010000" WHEN MINS = 19;
- HEX32 <= "01001001000000" WHEN MINS = 20;
- HEX32 <= "01001001111001" WHEN MINS = 21;
- HEX32 <= "01001000100100" WHEN MINS = 22;
- HEX32 <= "01001000110000" WHEN MINS = 23;
- HEX32 <= "01001000011001" WHEN MINS = 24;
- HEX32 <= "01001000010010" WHEN MINS = 25;
- HEX32 <= "01001000000010" WHEN MINS = 26;
- HEX32 <= "01001001111000" WHEN MINS = 27;
- HEX32 <= "01001000000000" WHEN MINS = 28;
- HEX32 <= "01001000010000" WHEN MINS = 29;
- HEX32 <= "01100001000000" WHEN MINS = 30;
- HEX32 <= "01100001111001" WHEN MINS = 31;
- HEX32 <= "01100000100100" WHEN MINS = 32;
- HEX32 <= "01100000110000" WHEN MINS = 33;
- HEX32 <= "01100000011001" WHEN MINS = 34;
- HEX32 <= "01100000010010" WHEN MINS = 35;
- HEX32 <= "01100000000010" WHEN MINS = 36;
- HEX32 <= "01100001111000" WHEN MINS = 37;
- HEX32 <= "01100000000000" WHEN MINS = 38;
- HEX32 <= "01100000010000" WHEN MINS = 39;
- HEX32 <= "00110011000000" WHEN MINS = 40;
- HEX32 <= "00110011111001" WHEN MINS = 41;
- HEX32 <= "00110010100100" WHEN MINS = 42;
- HEX32 <= "00110010110000" WHEN MINS = 43;
- HEX32 <= "00110010011001" WHEN MINS = 44;
- HEX32 <= "00110010010010" WHEN MINS = 45;
- HEX32 <= "00110010000010" WHEN MINS = 46;
- HEX32 <= "00110011111000" WHEN MINS = 47;
- HEX32 <= "00110010000000" WHEN MINS = 48;
- HEX32 <= "00110010010000" WHEN MINS = 49;
- HEX32 <= "00100101000000" WHEN MINS = 50;
- HEX32 <= "00100101111001" WHEN MINS = 51;
- HEX32 <= "00100100100100" WHEN MINS = 52;
- HEX32 <= "00100100110000" WHEN MINS = 53;
- HEX32 <= "00100100011001" WHEN MINS = 54;
- HEX32 <= "00100100010010" WHEN MINS = 55;
- HEX32 <= "00100100000010" WHEN MINS = 56;
- HEX32 <= "00100101111000" WHEN MINS = 57;
- HEX32 <= "00100100000000" WHEN MINS = 58;
- HEX32 <= "00100100010000" WHEN MINS = 59;
- HEX54 <= "10000001000000" WHEN SECS = 0;
- HEX54 <= "10000001111001" WHEN SECS = 1;
- HEX54 <= "10000000100100" WHEN SECS = 2;
- HEX54 <= "10000000110000" WHEN SECS = 3;
- HEX54 <= "10000000011001" WHEN SECS = 4;
- HEX54 <= "10000000010010" WHEN SECS = 5;
- HEX54 <= "10000000000010" WHEN SECS = 6;
- HEX54 <= "10000001111000" WHEN SECS = 7;
- HEX54 <= "10000000000000" WHEN SECS = 8;
- HEX54 <= "10000000010000" WHEN SECS = 9;
- HEX54 <= "11110011000000" WHEN SECS = 10;
- HEX54 <= "11110011111001" WHEN SECS = 11;
- HEX54 <= "11110010100100" WHEN SECS = 12;
- HEX54 <= "11110010110000" WHEN SECS = 13;
- HEX54 <= "11110010011001" WHEN SECS = 14;
- HEX54 <= "11110010010010" WHEN SECS = 15;
- HEX54 <= "11110010000010" WHEN SECS = 16;
- HEX54 <= "11110011111000" WHEN SECS = 17;
- HEX54 <= "11110010000000" WHEN SECS = 18;
- HEX54 <= "11110010010000" WHEN SECS = 19;
- HEX54 <= "01001001000000" WHEN SECS = 20;
- HEX54 <= "01001001111001" WHEN SECS = 21;
- HEX54 <= "01001000100100" WHEN SECS = 22;
- HEX54 <= "01001000110000" WHEN SECS = 23;
- HEX54 <= "01001000011001" WHEN SECS = 24;
- HEX54 <= "01001000010010" WHEN SECS = 25;
- HEX54 <= "01001000000010" WHEN SECS = 26;
- HEX54 <= "01001001111000" WHEN SECS = 27;
- HEX54 <= "01001000000000" WHEN SECS = 28;
- HEX54 <= "01001000010000" WHEN SECS = 29;
- HEX54 <= "01100001000000" WHEN SECS = 30;
- HEX54 <= "01100001111001" WHEN SECS = 31;
- HEX54 <= "01100000100100" WHEN SECS = 32;
- HEX54 <= "01100000110000" WHEN SECS = 33;
- HEX54 <= "01100000011001" WHEN SECS = 34;
- HEX54 <= "01100000010010" WHEN SECS = 35;
- HEX54 <= "01100000000010" WHEN SECS = 36;
- HEX54 <= "01100001111000" WHEN SECS = 37;
- HEX54 <= "01100000000000" WHEN SECS = 38;
- HEX54 <= "01100000010000" WHEN SECS = 39;
- HEX54 <= "00110011000000" WHEN SECS = 40;
- HEX54 <= "00110011111001" WHEN SECS = 41;
- HEX54 <= "00110010100100" WHEN SECS = 42;
- HEX54 <= "00110010110000" WHEN SECS = 43;
- HEX54 <= "00110010011001" WHEN SECS = 44;
- HEX54 <= "00110010010010" WHEN SECS = 45;
- HEX54 <= "00110010000010" WHEN SECS = 46;
- HEX54 <= "00110011111000" WHEN SECS = 47;
- HEX54 <= "00110010000000" WHEN SECS = 48;
- HEX54 <= "00110010010000" WHEN SECS = 49;
- HEX54 <= "00100101000000" WHEN SECS = 50;
- HEX54 <= "00100101111001" WHEN SECS = 51;
- HEX54 <= "00100100100100" WHEN SECS = 52;
- HEX54 <= "00100100110000" WHEN SECS = 53;
- HEX54 <= "00100100011001" WHEN SECS = 54;
- HEX54 <= "00100100010010" WHEN SECS = 55;
- HEX54 <= "00100100000010" WHEN SECS = 56;
- HEX54 <= "00100101111000" WHEN SECS = 57;
- HEX54 <= "00100100000000" WHEN SECS = 58;
- HEX54 <= "00100100010000" WHEN SECS = 59;
- END behavior;
- Output Errors:
- Error (10818): Can't infer register for "MINS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[0]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "MINS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[1]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "MINS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[2]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "MINS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[3]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "MINS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[4]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "MINS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "MINS[5]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[0]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[1]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[2]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[3]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[4]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "SECS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "SECS[5]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[0]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[0]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[1]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[1]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[2]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[2]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[3]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[3]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[4]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[4]" at GroupClockTest.vhd(33)
- Error (10818): Can't infer register for "HOURS[5]" at GroupClockTest.vhd(45) because it does not hold its value outside the clock edge
- Info (10041): Inferred latch for "HOURS[5]" at GroupClockTest.vhd(33)
- Error (10822): HDL error at GroupClockTest.vhd(45): couldn't implement registers for assignments on this clock edge
- Error (12153): Can't elaborate top-level user hierarchy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement