数字钟的设计.docx
- 文档编号:3262847
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:22
- 大小:115.45KB
数字钟的设计.docx
《数字钟的设计.docx》由会员分享,可在线阅读,更多相关《数字钟的设计.docx(22页珍藏版)》请在冰点文库上搜索。
数字钟的设计
课程设计报告
课程名称数字系统与逻辑设计
课题名称数字钟的设计
专业通信工程
班级
学号
姓名
指导教师乔汇东胡倩
2011年7月9日
湖南工程学院
课程设计任务书
课程名称数字系统与逻辑设计
课题数字钟的设计
专业班级通信09011
学生姓名
学号
指导老师乔汇东胡倩
审批乔汇东
任务书下达日期2011年7月2日
任务完成日期2011年7月9日
《数字系统与逻辑设计》课程设计任务书
一、设计目的
全面熟悉、掌握VHDL语言基本知识,掌握利用VHDL语言对常用的的组合逻辑电路和时序逻辑电路编程,把编程和实际结合起来,熟悉编制和调试程序的技巧,掌握分析结果的若干有效方法,进一步提高上机动手能力,培养使用设计综合电路的能力,养成提供文档资料的习惯和规范编程的思想。
二、设计要求
1、设计正确,方案合理。
2、程序精炼,结构清晰。
3、设计报告5000字以上,含程序设计说明,用户使用说明,源程序清单及程序框图。
4、上机演示。
5、有详细的文档。
文档中包括设计思路、设计仿真程序、仿真结果及相应的分析与结论。
三、进度安排
第二十周星期一:
课题讲解,查阅资料
星期二:
总体设计,详细设计
星期三:
编程,上机调试、修改程序
星期四:
上机调试、完善程序
星期五:
答辩
星期六-星期天:
撰写课程设计报告
附:
课程设计报告装订顺序:
封面、任务书、目录、正文、评分、附件(A4大小的图纸及程序清单)。
正文的格式:
一级标题用3号黑体,二级标题用四号宋体加粗,正文用小四号宋体;行距为22。
正文的内容:
一、课题的主要功能;二、课题的功能模块的划分(要求画出模块图);三、主要功能的实现;四、系统调试与仿真;五、总结与体会;六、附件(所有程序的原代码,要求对程序写出必要的注释);七、评分表。
目录
一、出租车计费系统的总体设计…………………………………1
1.1出租车计费设计…………………………………………….1
1.2基本设计思想……………………………………………….1
二、出租车计费系统的功能实现……………….…………………2
2.1系统的总体框图………………………………………….…2
2.2程序流程图…………………………………………..……3
2.3系统各功能模块的实现……………………………...….4
三、系统调试与仿真………..……………………………………11
四、总结与体会….……………………………………………….13
5、评分表………………………………………………………15
一、数字钟系统的总体设计
1.1数字钟的设计
多功能数字钟具有的功能有:
显示时-分-秒、整点报时、小时和分钟可调等基本功能。
整个钟表的工作是在1Hz信号的作用下进行,这样每来一个时钟信号,秒增加1秒,当秒从59秒跳转到00秒时,分钟增加1分,同时当分钟从59分跳转到00分时,小时增加1小时,由于系统提供的是1KHz的时钟驱动,所以必须使用分频器分出1Hz的的频率来驱动时钟的计数调时以及显示等。
1.2基本设计思想
在一个1KHz系统时钟的驱动下完成整个电路的输出,电路能正确的输出时、分、秒,并且根据用户的设定来改变时钟和分钟的值,有两个按键输入信号S1,S0,可以分别用来改变时钟和分钟的值以达到时间设定的目的。
同时在整点时分都应该输出一个整点报时信号,信号规律为1秒钟一个脉冲,持续5秒。
二、数字钟系统的功能实现
2.1系统的总体框图
2.2程序流程图
2.3系统各功能模块的实现
1、分频模块
模块的VHDL语言如下:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityfenpinis
port(clk:
instd_logic;
clk1:
outstd_logic);
end;
architectureoneoffenpinis
signalm:
integerrange0to999;
begin
process(clk)
begin
if(rising_edge(clk))then
ifm=999thenm<=0;clk1<='1';
elsem<=m+1;clk1<='0';
endif;
endif;
endprocess;
end;
仿真图如下:
图一
图二
2、报时模块
模块的VHDL语言如下:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitybaoshiis
port(clk:
std_logic;
rhou1,rhou0,rmin1,rmin0,rsec1,rsec0:
instd_logic_vector(3downto0);
ring:
outstd_logic);
end;
architecturebehavofbaoshiis----整点报时
begin
process(clk)
begin
if(rising_edge(clk))then
if(rmin1="0101"andrmin0="1001"andrsec1="0101")then
if(rsec0="0110"orrsec0="0111"orrsec0="1000")then
ring<='1';
elsering<='0';
endif;
elsif(rmin1="0000"andrmin0="0000"andrsec0="0000"andrsec1="0000")then
ring<='1';
elsering<='0';
endif;
endif;
endprocess;
end;
仿真图如下:
图三
图四
3、计数以及调时模块
模块的VHDL语言如下:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityaaais
port(clk1,reset,setmin,sethour:
instd_logic;
hou1,hou0,min1,min0,sec1,sec0:
bufferstd_logic_vector(3downto0));
endentityaaa;
architecturebehaofaaais
begin
process(clk1,reset,setmin,sethour)---时间设置
begin
if(reset='1')thensec0<="0000";sec1<="0000";
min0<="0000";min1<="0000";hou0<="0000";hou1<="0000";
elsifrising_edge(clk1)then
sec0<=sec0+1;-----正常计时工作
ifsec0="1001"then
sec0<="0000";sec1<=sec1+1;
ifsec1="0101"then
sec1<="0000";min0<=min0+1;
ifmin0="1001"then
min0<="0000";min1<=min1+1;
ifmin1="0101"then
min1<="0000";hou0<=hou0+1;
ifhou0="1001"then
hou1<="0000";hou1<=hou1+1;
endif;
ifhou0="0100"andhou1="0010"then
hou0<="0000";hou1<="0000";
endif;----------24小时制
endif;
endif;
endif;
endif;
ifsetmin='1'thenmin0<=min0+1;
ifmin0="1001"then
min0<="0000";
min1<=min1+1;
ifmin1="0101"then
min1<="0000";
endif;
endif;
endif;
ifsethour='1'thenhou0<=hou0+1;
ifhou1="0010"then
ifhou0="0011"thenhou1<="0000";hou0<="0000";
elsehou0<=hou0+1;
endif;
else
ifhou0="1001"then
hou0<="0000";hou1<=hou1+1;
endif;
endif;
endif;
endif;
endprocess;
end;
仿真图如下:
图五
图六
4、显示模块
模块的VHDL语言如下:
libraryieee;--显示模块
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityxianshiis
port(clk:
instd_logic;
q0:
instd_logic_vector(3downto0);
q1:
instd_logic_vector(3downto0);
q2:
instd_logic_vector(3downto0);
q3:
instd_logic_vector(3downto0);
q4:
instd_logic_vector(3downto0);
q5:
instd_logic_vector(3downto0);
sg:
outstd_logic_vector(6downto0);
bt:
outstd_logic_vector(7downto0));
end;
architectureoneofxianshiis
signalCNT:
std_logic_vector(2downto0);
signala:
std_logic_vector(3downto0);
begin
P1:
process(CNT)
begin
caseCNTis
when"000"=>BT<="00000001";a<=q0;
when"001"=>BT<="00000010";a<=q1;
when"010"=>BT<="00000100";a<="1010";
when"011"=>BT<="00001000";a<=q2;
when"100"=>BT<="00010000";a<=q3;
when"101"=>BT<="00100000";a<="1010";
when"110"=>BT<="01000000";a<=q4;
when"111"=>BT<="10000000";a<=q5;
whenothers=>NULL;
endcase;
endprocessP1;
P2:
process(clk)
begin
ifclk'EVENTandclk='1'thenCNT<=CNT+1;
endif;
endprocessP2;
P3:
process(a)
begin
caseais
when"0000"=>SG<="0111111";
when"0001"=>SG<="0000110";
when"0010"=>SG<="1011011";
when"0011"=>SG<="1001111";
when"0100"=>SG<="1100110";
when"0101"=>SG<="1101101";
when"0110"=>SG<="1111101";
when"0111"=>SG<="0000111";
when"1000"=>SG<="1111111";
when"1001"=>SG<="1101111";
when"1010"=>SG<="1000000";
whenothers=>NULL;
endcase;
endprocessP3;
end;
仿真图如下:
图七
图八
三、系统的调试与仿真
系统的VHDL语言:
libraryieee;
useieee.std_logic_1164.all;
entityheadis
port(clk,reset,s1,s2:
instd_logic;
q_out:
outstd_logic_vector(6downto0);
w_out:
outstd_logic_vector(7downto0));
end;
architecturewofheadis
componentfenping
port(clk:
instd_logic;
clk1:
outstd_logic);
endcomponent;
componentaaa
port(clk1,reset,s1,s2:
instd_logic;
hou1,hou0,min1,min0,sec1,sec0:
bufferstd_logic_vector(3downto0));
endcomponent;
componentxianshi
port(clk1:
instd_logic;
q0:
instd_logic_vector(3downto0);
q1:
instd_logic_vector(3downto0);
q2:
instd_logic_vector(3downto0);
q3:
instd_logic_vector(3downto0);
q4:
instd_logic_vector(3downto0);
q5:
instd_logic_vector(3downto0);
sg:
outstd_logic_vector(6downto0);
bt:
outstd_logic_vector(7downto0));
endcomponent;
signalb:
std_logic;
signala0,a1,a2,a3,a4,a5:
std_logic_vector(3downto0);
begin
u1:
fenpingportmap(clk=>clk,clk1=>b);
u2:
aaaportmap(reset=>reset,s1=>s1,s2=>s2,clk1=>b,sec0=>a0,sec1=>a1,min0=>a2,min1=>a3,hou0=>a4,hou1=>a5);
u3:
xianshiportmap(clk1=>b,q0=>a0,q1=>a1,q2=>a2,q3=>a3,q4=>a4,q5=>a5,sg=>q_out,bt=>w_out);
end;
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityfenpingis
port(clk:
instd_logic;
clk1:
outstd_logic);
end;
architectureoneoffenpingis
signalm:
integerrange0to999;
begin
process(clk)
begin
if(rising_edge(clk))then
ifm=999thenm<=0;clk1<='1';
elsem<=m+1;clk1<='0';
endif;
endif;
endprocess;
end;
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityaaais
port(clk1,reset,s1,s2:
instd_logic;
hou1,hou0,min1,min0,sec1,sec0:
bufferstd_logic_vector(3downto0));
endentityaaa;
architecturebehaofaaais
begin
process(clk1,reset,s1,s2)---时间设置
begin
if(reset='0')thensec0<="0000";sec1<="0000";
min0<="0000";min1<="0000";hou0<="0000";hou1<="0000";
elsifrising_edge(clk1)then
sec0<=sec0+1;-----正常计时工作
ifsec0="1001"then
sec0<="0000";sec1<=sec1+1;
ifsec1="0101"then
sec1<="0000";min0<=min0+1;
ifmin0="1001"then
min0<="0000";min1<=min1+1;
ifmin1="0101"then
min1<="0000";hou0<=hou0+1;
ifhou0="1001"then
hou1<="0000";hou1<=hou1+1;
endif;
ifhou0="0100"andhou1="0010"then
hou0<="0000";hou1<="0000";
endif;----------24小时制
endif;
endif;
endif;
endif;
ifs1='0'thenmin0<=min0+1;
ifmin0="1001"then
min0<="0000";
min1<=min1+1;
ifmin1="0101"then
min1<="0000";
endif;
endif;
endif;
ifs2='0'thenhou0<=hou0+1;
ifhou1="0010"then
ifhou0="0011"thenhou1<="0000";hou0<="0000";
elsehou0<=hou0+1;
endif;
else
ifhou0="1001"then
hou0<="0000";hou1<=hou1+1;
endif;
endif;
endif;
endif;
endprocess;
end;
libraryieee;--显示模块
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityxianshiis
port(clk1:
instd_logic;
q0:
instd_logic_vector(3downto0);
q1:
instd_logic_vector(3downto0);
q2:
instd_logic_vector(3downto0);
q3:
instd_logic_vector(3downto0);
q4:
instd_logic_vector(3downto0);
q5:
instd_logic_vector(3downto0);
sg:
outstd_logic_vector(6downto0);
bt:
outstd_logic_vector(7downto0));
end;
architectureoneofxianshiis
signalCNT:
std_logic_vector(2downto0);
signala:
std_logic_vector(3downto0);
begin
P1:
process(CNT)
begin
caseCNTis
when"000"=>BT<="00000001";a<=q0;
when"001"=>BT<="00000010";a<=q1;
when"010"=>BT<="00000100";a<="1010";
when"011"=>BT<="00001000";a<=q2;
when"100"=>BT<="00010000";a<=q3;
when"101"=>BT<="00100000";a<="1010";
when"110"=>BT<="01000000";a<=q4;
when"111"=>BT<="10000000";a<=q5;
whenothers=>NULL;
endcase;
endprocessP1;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字 设计
![提示](https://static.bingdoc.com/images/bang_tan.gif)