(2) 计数器模块:生成 60 进制、24 进制计数器
(3) 控制模块:按键控制、按键消抖
(4) 显示模块:7 段数码管显示器,分别显示小时、分钟、秒
(5) 报时模块:进行整点报时
2、各个模块的设计与仿真
2.1 分频模块
CLK 晶振频率 50MHZ,分成 2KHZ,1KHZ,1HZ 的信号。基准 1HZ 信号作为时钟计时的秒
计数时钟信号;分频的 1KHZ,2KHZ 信号用于报时电路的不同声讯。
程序代码:
library ieee;
use ieee.std_logic_1164.all;
entity fre is
port(
clk ,sel: in std_logic;
clk1hz,clk1khz,clk2khz:out std_logic);
end fre;
architecture beh of fre is
signal data1khz,data2khz,data1hz : std_logic := '0';
begin
clk1hz <= data1hz;
clk1khz <= data1khz;
clk2khz <= data2khz;
clk1khz_pro : process(clk) -- 产生
1khz 信号
variable cnt : integer range 0 to 24999;
begin
if clk'event and clk='1' then
if cnt = 24999 then
cnt := 0 ; data1khz <= not data1khz;
else
cnt := cnt + 1;
end if;
end if;
end process clk1khz_pro;
clk2khz_pro : process(clk) --产生
2khz 信号
variable cnt : integer range 0 to 12499;
begin
if clk'event and clk='1' then
if cnt = 12499 then
cnt := 0 ; data2khz <= not data2khz;
else