Line 195... |
Line 195... |
|
|
uSec_Cntr <= uSec_Cntr - 1;
|
uSec_Cntr <= uSec_Cntr - 1;
|
uSec_Tick_i <= '0';
|
uSec_Tick_i <= '0';
|
if( uSec_Cntr = 0 )then
|
if( uSec_Cntr = 0 )then
|
uSec_Cntr <= DLY_1USEC;
|
uSec_Cntr <= DLY_1USEC;
|
uSec_Tick_i <= or_reduce(Interval);
|
uSec_Tick_i <= '1';
|
end if;
|
end if;
|
|
|
pit.timer_ro <= '0';
|
|
|
|
rtc.frac_ro <= '0';
|
|
rtc.tens_l_ro <= '0';
|
|
rtc.tens_u_ro <= '0';
|
|
rtc.secs_l_ro <= '0';
|
|
rtc.secs_u_ro <= '0';
|
|
rtc.mins_l_ro <= '0';
|
|
rtc.mins_u_ro <= '0';
|
|
rtc.hours_l_ro <= '0';
|
|
rtc.hours_u_ro <= '0';
|
|
|
|
-- Periodic Interval Timer
|
-- Periodic Interval Timer
|
pit.timer_cnt <= pit.timer_cnt - uSec_Tick_i;
|
pit.timer_cnt <= pit.timer_cnt - uSec_Tick_i;
|
|
pit.timer_ro <= '0';
|
if( or_reduce(pit.timer_cnt) = '0' )then
|
if( or_reduce(pit.timer_cnt) = '0' )then
|
pit.timer_cnt <= interval;
|
pit.timer_cnt <= interval;
|
pit.timer_ro <= or_reduce(interval); -- Only issue output on Int > 0
|
pit.timer_ro <= or_reduce(interval); -- Only issue output on Int > 0
|
end if;
|
end if;
|
|
|
-- Fractional decisecond counter - cycles every 10k microseconds
|
-- Fractional decisecond counter - cycles every 10k microseconds
|
rtc.frac <= rtc.frac - uSec_Tick_i;
|
rtc.frac <= rtc.frac - uSec_Tick_i;
|
|
rtc.frac_ro <= '0';
|
if( or_reduce(rtc.frac) = '0' or update_rtc = '1' )then
|
if( or_reduce(rtc.frac) = '0' or update_rtc = '1' )then
|
rtc.frac <= DECISEC;
|
rtc.frac <= DECISEC;
|
rtc.frac_ro <= not update_rtc;
|
rtc.frac_ro <= not update_rtc;
|
end if;
|
end if;
|
|
|
-- Decisecond counter (lower)
|
-- Decisecond counter (lower)
|
rtc.tens_l <= rtc.tens_l + rtc.frac_ro;
|
rtc.tens_l <= rtc.tens_l + rtc.frac_ro;
|
|
rtc.tens_l_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.tens_l <= shd_tens(3 downto 0);
|
rtc.tens_l <= shd_tens(3 downto 0);
|
elsif( rtc.tens_l > x"9")then
|
elsif( rtc.tens_l > x"9")then
|
rtc.tens_l <= (others => '0');
|
rtc.tens_l <= (others => '0');
|
rtc.tens_l_ro <= '1';
|
rtc.tens_l_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Decisecond counter (upper)
|
-- Decisecond counter (upper)
|
rtc.tens_u <= rtc.tens_u + rtc.tens_l_ro;
|
rtc.tens_u <= rtc.tens_u + rtc.tens_l_ro;
|
|
rtc.tens_u_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.tens_u <= shd_tens(7 downto 4);
|
rtc.tens_u <= shd_tens(7 downto 4);
|
elsif( rtc.tens_u > x"9")then
|
elsif( rtc.tens_u > x"9")then
|
rtc.tens_u <= (others => '0');
|
rtc.tens_u <= (others => '0');
|
rtc.tens_u_ro <= '1';
|
rtc.tens_u_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Second counter (lower)
|
-- Second counter (lower)
|
rtc.secs_l <= rtc.secs_l + rtc.tens_u_ro;
|
rtc.secs_l <= rtc.secs_l + rtc.tens_u_ro;
|
|
rtc.secs_l_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.secs_l <= shd_secs(3 downto 0);
|
rtc.secs_l <= shd_secs(3 downto 0);
|
elsif( rtc.secs_l > x"9")then
|
elsif( rtc.secs_l > x"9")then
|
rtc.secs_l <= (others => '0');
|
rtc.secs_l <= (others => '0');
|
rtc.secs_l_ro <= '1';
|
rtc.secs_l_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Second counter (upper)
|
-- Second counter (upper)
|
rtc.secs_u <= rtc.secs_u + rtc.secs_l_ro;
|
rtc.secs_u <= rtc.secs_u + rtc.secs_l_ro;
|
|
rtc.secs_u_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.secs_u <= shd_secs(7 downto 4);
|
rtc.secs_u <= shd_secs(7 downto 4);
|
elsif( rtc.secs_u > x"5")then
|
elsif( rtc.secs_u > x"5")then
|
rtc.secs_u <= (others => '0');
|
rtc.secs_u <= (others => '0');
|
rtc.secs_u_ro <= '1';
|
rtc.secs_u_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Minutes counter (lower)
|
-- Minutes counter (lower)
|
rtc.mins_l <= rtc.mins_l + rtc.secs_u_ro;
|
rtc.mins_l <= rtc.mins_l + rtc.secs_u_ro;
|
|
rtc.mins_l_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.mins_l <= shd_mins(3 downto 0);
|
rtc.mins_l <= shd_mins(3 downto 0);
|
elsif( rtc.mins_l > x"9")then
|
elsif( rtc.mins_l > x"9")then
|
rtc.mins_l <= (others => '0');
|
rtc.mins_l <= (others => '0');
|
rtc.mins_l_ro <= '1';
|
rtc.mins_l_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Minutes counter (upper)
|
-- Minutes counter (upper)
|
rtc.mins_u <= rtc.mins_u + rtc.mins_l_ro;
|
rtc.mins_u <= rtc.mins_u + rtc.mins_l_ro;
|
|
rtc.mins_u_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.mins_u <= shd_mins(7 downto 4);
|
rtc.mins_u <= shd_mins(7 downto 4);
|
elsif( rtc.mins_u > x"5")then
|
elsif( rtc.mins_u > x"5")then
|
rtc.mins_u <= (others => '0');
|
rtc.mins_u <= (others => '0');
|
rtc.mins_u_ro <= '1';
|
rtc.mins_u_ro <= '1';
|
end if;
|
end if;
|
|
|
-- Hour counter (lower)
|
-- Hour counter (lower)
|
rtc.hours_l <= rtc.hours_l + rtc.mins_u_ro;
|
rtc.hours_l <= rtc.hours_l + rtc.mins_u_ro;
|
|
rtc.hours_l_ro <= '0';
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.hours_l <= shd_hours(3 downto 0);
|
rtc.hours_l <= shd_hours(3 downto 0);
|
elsif( rtc.hours_l > x"9")then
|
elsif( rtc.hours_l > x"9")then
|
rtc.hours_l <= (others => '0');
|
rtc.hours_l <= (others => '0');
|
rtc.hours_l_ro <= '1';
|
rtc.hours_l_ro <= '1';
|
Line 293... |
Line 290... |
rtc.hours_u <= rtc.hours_u + rtc.hours_l_ro;
|
rtc.hours_u <= rtc.hours_u + rtc.hours_l_ro;
|
if( update_rtc = '1' )then
|
if( update_rtc = '1' )then
|
rtc.hours_u <= shd_hours(7 downto 4);
|
rtc.hours_u <= shd_hours(7 downto 4);
|
end if;
|
end if;
|
|
|
|
rtc.hours_u_ro <= '0';
|
if( rtc.hours_u >= x"2" and rtc.hours_l > x"3" )then
|
if( rtc.hours_u >= x"2" and rtc.hours_l > x"3" )then
|
rtc.hours_l <= (others => '0');
|
rtc.hours_l <= (others => '0');
|
rtc.hours_u <= (others => '0');
|
rtc.hours_u <= (others => '0');
|
rtc.hours_u_ro <= '1';
|
rtc.hours_u_ro <= '1';
|
end if;
|
end if;
|