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