Altera_Forum
Honored Contributor
11 years agocan you check the error for stopwatch using de2 board
the error is that after 59min it goes 60 61 62min....... after 99min, it become 00min 00s00
actually it need to change in hour after 59min i want to show my stopwatch for max 99hr 59min 59s99 this is the stopwatch coding using VHDL library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity stop_watch is Port ( clk : in STD_LOGIC; start : in STD_LOGIC; reset : in STD_LOGIC; hex0 : out STD_LOGIC_VECTOR (3 downto 0); hex1 : out STD_LOGIC_VECTOR (3 downto 0); hex2 : out STD_LOGIC_VECTOR (3 downto 0); hex3 : out STD_LOGIC_VECTOR (3 downto 0); hex4 : out STD_LOGIC_VECTOR (3 downto 0); hex5 : out STD_LOGIC_VECTOR (3 downto 0); hex6 : out STD_LOGIC_VECTOR (3 downto 0); hex7 : out STD_LOGIC_VECTOR (3 downto 0)); end stop_watch; architecture Behavioral of stop_watch is signal count0:std_logic_vector(3 downto 0):=(others=>'0'); signal count1:std_logic_vector(3 downto 0):=(others=>'0'); signal count2:std_logic_vector(3 downto 0):=(others=>'0'); signal count3:std_logic_vector(3 downto 0):=(others=>'0'); signal count4:std_logic_vector(3 downto 0):=(others=>'0'); signal count5:std_logic_vector(3 downto 0):=(others=>'0'); signal count6:std_logic_vector(3 downto 0):=(others=>'0'); signal count7:std_logic_vector(3 downto 0):=(others=>'0'); begin process(clk,reset) begin if reset='1' then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=(others=>'0'); count5<=(others=>'0'); count6<=(others=>'0'); count7<=(others=>'0'); elsif rising_edge(clk) then if start='1' then if (count7=x"9" and count6=x"9" and count5=x"5" and count4=x"9" and count3=x"5" and count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=(others=>'0'); count5<=(others=>'0'); count6<=(others=>'0'); count7<=(others=>'0'); elsif (count6=x"9" and count5=x"5" and count4=x"9" and count3=x"5" and count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=(others=>'0'); count5<=(others=>'0'); count6<=(others=>'0'); count7<=count7+1; elsif (count5=x"5" and count4=x"9" and count3=x"5" and count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=(others=>'0'); count5<=(others=>'0'); count6<=count6+1; elsif (count4=x"9" and count3=x"5" and count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=(others=>'0'); count5<=count5 + 1; elsif (count3=x"5" and count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=(others=>'0'); count4<=count4 + 1; elsif (count2=x"9" and count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=(others=>'0'); count3<=count3 + 1; elsif (count1=x"9" and count0=x"9") then count0<=(others=>'0'); count1<=(others=>'0'); count2<=count2 + 1; elsif (count0=x"9") then count0<=(others=>'0'); count1<=count1 + 1; else count0<=count0 + 1; end if; end if; end if; end process; hex0<=count0; hex1<=count1; hex2<=count2; hex3<=count3; hex4<=count4; hex5<=count5; hex6<=count6; hex7<=count7; end Behavioral;