具有篮球倒计时的数字钟.docx

上传人:b****3 文档编号:4981308 上传时间:2022-12-12 格式:DOCX 页数:13 大小:367.61KB
下载 相关 举报
具有篮球倒计时的数字钟.docx_第1页
第1页 / 共13页
具有篮球倒计时的数字钟.docx_第2页
第2页 / 共13页
具有篮球倒计时的数字钟.docx_第3页
第3页 / 共13页
具有篮球倒计时的数字钟.docx_第4页
第4页 / 共13页
具有篮球倒计时的数字钟.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

具有篮球倒计时的数字钟.docx

《具有篮球倒计时的数字钟.docx》由会员分享,可在线阅读,更多相关《具有篮球倒计时的数字钟.docx(13页珍藏版)》请在冰豆网上搜索。

具有篮球倒计时的数字钟.docx

具有篮球倒计时的数字钟

VHDL语言及数字电路课程设计

说明书

——装订线——

设计题目具有篮球倒计时的数字钟

 

系别机电系

专业班级10应用电子技术

学生姓名杨华培

学号1010401028

指导教师吴小玲老师

日期2012.06.25

 

一.项目要求

例如:

设计一个电子数字钟,具体要求如下:

(1)有调时,调分按键。

(2)具有时钟复位,倒计时复位按键。

(3)设有一个时钟模式和倒计时模式的切换键。

(4)倒计时分别从14秒或24秒倒计,计到0是有报警

二.设计方案

1.项目分析

本设计是基于ACEX1K系列芯片设计的。

显示界面为一个8位的LED数码管,时间显示方式为8位同时显示,即显示状态为:

88-88-88。

显示的时间制为24小时制。

当按下切换键时,显示倒计时模式为两位数码管显示。

本设计有7个按键,分别为clr(选择24秒倒计时),pld(选择14秒倒计时),enb(倒计时使能)setmin(数字钟调分),sethour(数字钟调时),reset(数字钟复位),k(数字钟和倒计时切换键)。

2.系统设计

2.1设计方案:

数字钟模块:

蓝球倒计时模块:

总体模块:

2.2各模块分析

2.2.1模块一(时钟模块)

该模块主要有两个小模块组成,分别为计时模块和模块,程序如下:

--计数模块—

--

(1)24计数器

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityhouris

port(clk,reset:

instd_logic;

hour_l:

outstd_logic_vector(3downto0);

hour_h:

outstd_logic_vector(3downto0));

endhour;

architectureabcofhouris

signalcount_l:

std_logic_vector(3downto0);

signalcount_h:

std_logic_vector(3downto0);

begin

hour_l<=count_l;

hour_h<=count_h;

process(clk,reset)

begin

if(reset='0')thencount_l<="0000";count_h<="0000";--复位

elsif(clk'eventandclk='1')then

if(count_h="0010"andcount_l="0011")then--满23时,个位、十位清零;

count_h<="0000";count_l<="0000";

elsif(count_l="1001")then--十位不为2,个位为9时;个位清零、十位加1

count_l<="0000";count_h<=count_h+1;

elsecount_l<=count_l+1;--其它情况下,个位加1,十位不变

endif;

endif;

endprocess;

endabc;

--

(2)60计数器

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityminuteis

port(clk,reset,sethour:

instd_logic;--时钟信号、复位信号、时间设置信号

enhour:

outstd_logic;

minout_l:

outstd_logic_vector(3downto0);

minout_h:

outstd_logic_vector(3downto0));

endminute;

architectureabcofminuteis

signalcount_l:

std_logic_vector(3downto0);

signalcount_h:

std_logic_vector(3downto0);

signalenhour_1:

std_logic;

begin

minout_l<=count_l;

minout_h<=count_h;

enhour<=(enhour_1orsethour);

process(clk,reset,sethour)

begin

if(reset='0')thencount_l<="0000";count_h<="0000";

elsif(clk'eventandclk='1')then

if(count_h="0101"andcount_l="1001")then--满59时,个位、十位清零,给下一个模块产生进位输出

count_h<="0000";count_l<="0000";enhour_1<='1';

elsif(count_l="1001")then

count_l<="0000";count_h<=count_h+1;--十位不为5,个位为9时;个位清零、十位加1

elsecount_l<=count_l+1;enhour_1<='0';--其它情况下,个位加1,十位不变

endif;

endif;

endprocess;

endabc;

 

--显示模块---

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityddispis

port(clk:

instd_logic;

a,b,c,d,e,f,g,h:

instd_logic_vector(3downto0);

com:

outstd_logic_vector(2downto0);

seg:

outstd_logic_vector(6downto0));

endddisp;

architectureartofddispis

signalcnt:

std_logic_vector(2downto0);

signalbcd:

std_logic_vector(3downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

ifcnt="111"then

cnt<="000";

elsecnt<=cnt+'1';

endif;

endif;

endprocess;

process(cnt,bcd,a,b,c,d,e,f,g)

begin

casecntis

when"000"=>bcd<=a;com<="000";

when"001"=>bcd<=b;com<="001";

when"010"=>bcd<=c;com<="010";

when"011"=>bcd<=d;com<="011";

when"100"=>bcd<=e;com<="100";

when"101"=>bcd<=f;com<="101";

when"110"=>bcd<=g;com<="110";

when"111"=>bcd<=h;com<="111";

endcase;

endprocess;

process(bcd)

begin

casebcdis

when"0000"=>seg<="1111110";

when"0001"=>seg<="0110000";

when"0010"=>seg<="1101101";

when"0011"=>seg<="1111001";

when"0100"=>seg<="0110011";

when"0101"=>seg<="1011011";

when"0110"=>seg<="1011111";

when"0111"=>seg<="1110000";

when"1000"=>seg<="1111111";

when"1001"=>seg<="1111011";

when"1010"=>seg<="0000001";

whenothers=>seg<="0000000";

endcase;

endprocess;

endart;

由上面的各个子模组成了数字钟模块,用图形编辑实现,截图如下:

2.2.2模块二(篮球倒计时模块)

该模块分为2个子模块,分别为24、14倒计时和显示模块,程序如下:

--(24、14倒计时)

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitybsjsbis

port(clr,pld,enb,clk:

instd_logic;

warn:

outstd_logic;

ddout:

outstd_logic_vector(3downto0);

ssout:

outstd_logic_vector(3downto0));

endbsjsb;

architectureartofbsjsbis

begin

process(clk,clr,enb)

variabletmpa:

std_logic_vector(3downto0);

variabletmpb:

std_logic_vector(3downto0);

variabletmpwarn:

std_logic;

begin

ifclr='1'then

tmpa:

="0100";

tmpb:

="0010";

tmpwarn:

='0';

elsifclk'eventandclk='1'then

ifpld='1'then

tmpb:

="0001";

tmpa:

="0100";

elsifenb='1'then

iftmpa="0000"then

iftmpb/="0000"then

tmpa:

="1001";

tmpb:

=tmpb-1;

else

tmpwarn:

='1';

endif;

elsetmpa:

=tmpa-1;

endif;

endif;

endif;

ssout<=tmpa;

ddout<=tmpb;

warn<=tmpwarn;

endprocess;

endart;

--(显示模块)

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitydispis

port(clk:

instd_logic;

a,b:

instd_logic_vector(3downto0);

com:

outstd_logic_vector(2downto0);

seg:

outstd_logic_vector(6downto0));

enddisp;

architectureartofdispis

signalcnt:

std_logic_vector(2downto0);

signalbcd:

std_logic_vector(3downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

ifcnt="001"then

cnt<="000";

elsecnt<=cnt+'1';

endif;

endif;

endprocess;

process(cnt,bcd,a,b)

begin

casecntis

when"000"=>bcd<=a;com<="000";

when"001"=>bcd<=b;com<="001";

whenothers=>bcd<="ZZZZ";

endcase;

endprocess;

process(bcd)

begin

casebcdis

when"0000"=>seg<="1111110";

when"0001"=>seg<="0110000";

when"0010"=>seg<="1101101";

when"0011"=>seg<="1111001";

when"0100"=>seg<="0110011";

when"0101"=>seg<="1011011";

when"0110"=>seg<="1011111";

when"0111"=>seg<="1110000";

when"1000"=>seg<="1111111";

when"1001"=>seg<="1111011";

whenothers=>seg<="0000000";

endcase;

endprocess;

endart;

由上面的各个子模组成了倒计时模块,用图形编辑实现,截图如下:

2.3顶层文件

顶层文件是用图形编辑实现的,截图如下:

2.4仿真分析

2.5芯片管脚分配

2.6下载

三.课程设计总结

本次设计综合了数字钟和倒计时两个模块为一个整体,通过一个切换功能模块来让用户选择使用哪个功能。

由于时间紧迫,这个设计的程序编写不是很完善,如数字钟没有减时、分按键,只有加按键;在倒计时模式下,14秒倒计时开启时,报警信号不能停止,只能先从24倒计时切换到14秒倒计时时才能解决这问题,所以,程序有待改进。

通过这次课程设计,让我们对用EDA编写一个完整的项目有了进一步的了解。

加强了我们的实操能力。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1