process (Clk50,rst)
begin
if Rst='1' then
mhertz_en<='0';
mhertz_count<=(others=>'0');
elsif Clk50'event and Clk50='1' then
mhertz_count<=mhertz_count + 1;
if mhertz_count="110010" then
mhertz_en<='1';
mhertz_count<=(others=>'0');
else
mhertz_en<='0';
end if;
end if;
end process;
-- Generate 1HZ signal from 1Mhz signal
process (Clk50,rst)
begin
if Rst='1' then
hertz_en<='0';
hertz_count<=(others=>'0');
elsif Clk50'event and Clk50='1' then
if mhertz_en='1' then
hertz_count<=hertz_count + 1;
if hertz_count="11110100001001000000" then
hertz_en<='1';
hertz_count<=(others=>'0');
else
hertz_en<='0';
end if;
else
hertz_en<='0';
end if;
end if;
end process;