Sec 2
Sec 2
Sec 2
1.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity clockmodule is
port (clk1 : in std_logic;
seconds : out std_logic_vector(5 downto 0));
end clockmodule;
begin
seconds <= conv_std_logic_vector(sec,6);
output waveform:
2. Display the second count on two 7-segment LED display. The count must
start from 0 and must be finish at 60.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity clockmodule is
port (clk1 : in std_logic;
clks :in std_logic;
bt_min0, bt_min1, bt_hour : in std_logic;
An: out std_logic_vector(3 downto 0);
disp : out std_logic_vector(6 downto 0);
end clockmodule;
begin
realclock: process (clks, bt_min0, bt_min1, bt_hour )
begin
if (rsisng_edge(clks)) then
min0 <= min0 + 1;
sec <= 0;
if (min0 =10) then
min1 <= min1 +1;
min0 <= 0;
if (min1 = 6) then
hour0 <= hour0 +1;
min0 <=0;
min1 <= 1;
hour0 <= 0;
end if;
end if;
end if;
elsif(bt_min1 = '1') then
min1 <= min1 +1;
elsif (bt_hour ='1') then
hour0 <= hour0 +1;
end if;
end if;
end process;
when 1 =>
tmp_an <= "1101";
if (min1 = 0) then
disp <= ""1000000";
elsif min1= 1 then
disp <= "1111001";
elsif min1= 2 then
disp <= "0100100";
elsif min1= 3 then
disp <= "0110000";
elsif min1= 4 then
disp <= "0011001";
elsif min1= 5 then
disp <= "0010010";
elsif min1= 6 then
disp <= "10000000";
end if;
when 2 =>
tmp_an <= "1011";
if (min0 = 0) then
disp <= ""1000000";
elsif hour0= 1 then
disp <= "1111001";
elsif hour0= 2 then
disp <= "0100100";
elsif hour0= 3 then
disp <= "0110000";
elsif hour0= 4 then
disp <= "0011001";
elsif hour0= 5 then
disp <= "0010010";
elsif hour0= 6 then
disp <= "0000010";
elsif hour0= 7 then
disp <= "1111000";
elsif hour0= 8 then
disp <= "0000000";
elsif hour0= 9 then
disp <= "0011000";
elsif hour0= 10 then
disp <= "1000000";
elsif hour0= 11 then
disp <= "1111001";
elsif hour0= 12 then
disp <= "0100100";
elsif hour0= 13 then
disp <= "1000000";
end if;
when 3 =>
tmp_an <= "0111";
if hour0= 10 then
disp <= "1111001";
elsif hour0= 11 then
disp <= "1111001";
elsif hour0= 12 then
disp <= "1111001";
else
disp <= "10000000";
end if;
end case;
end process;
end behavioral;