利用VHDL语言设计的数字钟..doc
文本预览下载声明
一、题目:数字钟
二、设计目的
掌握各类计数器和分频器以及它们相连的设计方法;掌握多个数码管的原理与方法;掌握CPLD技术的层次化设计的方法;掌握使用VHDL语言的设计思想;对整个系统的设计有一个了解。
三、设计系统环境
(1)一台PC机;
(2)一套GW48型EDA实验开发系统硬件;
(3)X+PLUS Ⅱ集成化的开发系统硬件。
四、设计要求
能进行正常的时、分、秒计时功能,分别由6个数码管显示24h、60min、60s。
按下sa键时,计时器迅速递增,并按24h循环,计时满23h后回00。
按下sb键时,计时器迅速递增,并按60min循环,计时满59min后回00。
(4)输入的时钟信号为3MHz。
五、总体框图
六、模块及模块功能
模块CNT60_2 该模块为60进制计数器,计时输出为秒的数值,在计时到59时送出进位信号CO,因为硬件有延时,所以模块CNT60_2在此模块变为00时加1,符合实际。
A、模块
B、程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt60_2 is
port(clk:in std_logic;
s1,s0:out std_logic_vector(3 downto 0);
co:out std_logic);
end cnt60_2;
architecture behav of cnt60_2 is
begin
process(clk)
variable cnt1,cnt0:std_logic_vector(3 downto 0);
begin
if clkevent and clk=1 then
if cnt1=0101 and cnt0=1000 then
co=1;
cnt0:=1001;
elsif cnt01001 then
cnt0:=cnt0+1;
else cnt0:=0000;
if cnt10101 then
cnt1:=cnt1+1;
else cnt1:=0000;
co=0;
end if;
end if;
end if;
s1=cnt1;
s0=cnt0;
end process;
end behav;
C、流程图
D、波形仿真
(2)模块CNT60_1 该模块为60进制计数器,计时输出为分的数值,在EN信号有效且时钟到来时,计数器加1。在sb按下时,EN信号有效,计数值以秒的速度增加,从而实现对分钟的设置。
模块
B、程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt60_1 is
port(en,clk:in std_logic;
min1,min0:out std_logic_vector(3 downto 0);
co:out std_logic);
end cnt60_1;
architecture behav of cnt60_1 is
begin
process(clk)
variable cnt1,cnt0:std_logic_vector(3 downto 0);
begin
if clkevent and clk=1 then
if en=1 then
if cnt1=0101 and cnt0=1000 then
co=1;
cnt0:=1001;
elsif cnt01001 then
cnt0:=cnt0+1;
else cnt0:=0000;
if cnt10101 then
cnt1:=cnt1+1;
else cnt1:=0000;
co=0;
end if;
end if;
end if;
end if;
min1=cnt1;
min0=cnt0;
end process;
end behav;
C、流程图
D、波形仿真
模块CNT24 该模块为24进制计数器,计时输出为小时的数值,在EN信号有效且时钟到来时,计数器加1。在sa按下时,EN信号有效,计数值以秒的速度增加,从而实现对时钟的设置。
A、模块
B、程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt24 is
port(en,clk:in std_logic;
显示全部