Professional Documents
Culture Documents
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity rtc is
Port (clk : in std_logic;
rst : in std_logic;
sl
: out std_logic_vector(5 downto 0);
atoh : out std_logic_vector(7 downto 0));
end rtc;
architecture Behavioral of rtc is
signal sig2 : std_logic_vector(26 downto 0) := (others => '0');
signal sig3 : std_logic_vector(19 downto 0) := (others => '0');
begin
process(clk, rst)
variable ssdigit1, ssdigit2,
ssdigit3, ssdigit4,
ssdigit5, ssdigit6 : std_logic_vector(7 downto 0) := (others => '0');
variable digit1, digit2,
digit3, digit4,
digit5, digit6
: integer := 0;
begin
if (rst = '0') then
digit1 := 0;
digit2 := 0;
digit3 := 0;
digit4 := 0;
digit5 := 0;
digit6 := 0;
sig2 <= (others => '0');
sig3 <= (others => '0');
elsif rising_edge(clk) then
sig2 <= sig2 + 1;
case sig2(24 downto 23) is
when "00" =>
digit6 := digit6 + 1;
if (digit6 > 9) then
digit6 := 0;
digit5 := digit5 + 1;
if (digit5 > 5) then
digit5 := 0;
digit4 := digit4 + 1;
if (digit4 > 9) then
digit4 := 0;
digit3 := digit3 + 1;
if (digit3 > 5) then
digit2 := digit2 + 1;
digit3 := 0;
if (digit2 > 9) then
digit1 := digit1 + 1;
digit2 := 0;
if ((digit1 >= 2) and (digit2 >= 4)) then
digit1 := 0;
digit2 := 0;
end if;
end if;
end if;
end if;
end if;
end if;
sig2(24 downto 23) <= "01";
when "11" =>
if (sig2(22 downto 19) = "1001") then
sig2 <= (others => '0');
end if;
when others =>
end case;
sig3 <= sig3 + 1;
case sig3(17 downto 15) is
when "000" => sl <= "111110";
case digit1 is
when 0 => ssdigit1 := "00111111";
when 1 => ssdigit1 := "00000110";
when 2 => ssdigit1 := "01011011";
when others => ssdigit1 := "00000000";
end case;
atoh <= ssdigit1;
when "001" => sl <= "111101";
case digit2 is
when 0 => ssdigit2 := "00111111";