二、试验项目名称:
基于vhdl语言的数码管时钟设计
三、实验目的:
利用FPGA开发板上的数码管,晶振等资源设计出能够显示时、分、秒的时钟。
四、实验内容及原理:
(一)、综述
本实验目标是利用FPGA逻辑资源,编程设计实现一个数字电子时钟。实验环境为fpga开发板。电路设计采用VHDL硬件描述语言编程实现,。
(二)、模块框架设计
计数时钟由模为60的秒计数器模块、模为60的分计数模块、模为24的小时计数器模块、此外还有最后的数码管显示模块。
综合计时模块
包括计时及进位两个进程,实现时钟逻辑功能。
显示模块
将时钟的每次变化所对应的时间及时输出到数码管上。实质为数码管译码
器。
(三)、VHDL编程与仿真:
1、各个进程模块
以下三个process分别为分频,进位以及计时进程。分频进程用于统计CLK输入信号输出完整的1秒。进位进程控制60进制,60进制和24进制的进位关系。计时进程用于实现电子时钟的基本计时功能,即每秒均变化。
---------------------分频部分-----------------
process(clk,reset)
begin
if(reset='0')then
cnt<=0;
elsif(clk'event and clk='1')then
cnt<=cnt+1;
t=50000000)then ----开发板晶振50M,统计到此时为1S
cnt<=0;
end if;
end if;
end process;
------------------------------------------------
进位共包括秒个位向秒十位进位,秒十位向分个位进位,分个位向分十位进位,分十位向时个位进位,时个位向时十位进位。根据进位规则则可以实现从0时0分0秒到23时59分59秒之间任意时刻的显示。
-------------各位的进位标志--------------------------
process(clk,reset)
begin
if reset='0'then
jinwei<="000000";
elsif clk'event and clk='1'then
if dataout_buf(0)=9 then
jinwei(0)<='1'; -----9S时向秒十位进位------
else
jinwei(0)<='0';
end if;
if(jinwei(0)='1'and dataout_buf(1)=5)then
jinwei(1)<='1'; ------59S时向分个位进位-------
else
jinwei(1)<='0';
end if;
if(jinwei(1)='1' and dataout_buf(3)=9)then
jinwei(2)<='1'; -----9分且秒十位进位时向分十位进位
else
jinwei(2)<='0';
end if;
if(jinwei(2)='1' and dataout_buf(4)=5)then
jinwei(3)<='1'; -----分十位为5且分个位进位时向时个位进位
else
jinwei(3)<='0';
end if;
if(jinwei(3)='1' and dataout_buf(6)=9)then
jinwei(4)<='1'; ----时个位为9且分十位进位时向时十位进位
else
jinwei(4)<='0';
end if;
if(jinwei(4)='1' and dataout_buf(6)=2 and dataout_buf(7)=1)then
jinwei(5)<='1'; ----到12时且时个位进位时标记最高标记位
else
jinwei(5)<='0';
end if;
end if;
end process;
---------------------------------------------------
计数进程,其进程逻辑上受分频输出与进位控制,当分频输出变化(即每秒),秒个位自加,当满足进位条件时,调用进位规则,进行时间的跳转。
--------------------计数---------------------
t,reset,dataout_buf,jinwei)
begin
if(reset='0')then
dataout_buf(0)<=0;
d
基于vhdl电子时钟设计说明书 来自淘豆网m.daumloan.com转载请标明出处.