课程设计报告作业.docx
《课程设计报告作业.docx》由会员分享,可在线阅读,更多相关《课程设计报告作业.docx(10页珍藏版)》请在冰点文库上搜索。
课程设计报告作业
武汉纺织大学数学与计算机学院
逻辑设计课程设计报告
数字钟的设计
班级:
计科0921
学号:
0914791010
姓名:
陈谨欣
同组者:
陈林
日期:
2010/6/30
1题目与要求
1.1问题提出
1、秒、分为00~59六十进制计数器。
2、时为00~23二十四进制计数器。
3、整点报时。
4、数码管显示。
5、其它功能(如:
星期计数等)
1.2设计原理
通过程序编程和仿真及下载,而使功能得以实现。
它由石英晶体振荡器、分频器、计数器、译码器显示器和校时电路组成。
振荡器产生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。
秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照“24翻1”规律计数。
计数器的输出分别经译码器送显示器显示。
计时出现误差时,可以用校时电路校时、校分。
2设计过程
2.1逻辑描述
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityclockis
port(clk,switch,clear,add:
instd_logic;
set:
instd_logic_vector(1downto0);
second0,second1,minute0,minute1,hour0,hour1:
outstd_logic_vector(3downto0));
end;
architecturearchofclockis
signalclk0,clr,m0,m1,m2,m3,m4:
std_logic;
signalcout0:
std_logic_vector(3downto0);
signalcout1:
std_logic_vector(3downto0);
signalcout2:
std_logic_vector(3downto0);
signalcout3:
std_logic_vector(3downto0);
signalcout4:
std_logic_vector(3downto0);
signalcout5:
std_logic_vector(3downto0);
begin
start:
process(switch)
begin
if(switch='0')then
clk0<=clk;
else
if(add='1')then
clk0<='1';
else
clk0<='0';
endif;
endif;
endprocessstart;
p1:
process(clr,clk0)
begin
if(set="00"orset="01")then
if(clr='1')then
cout0<="0000";m0<='0';
elsif(rising_edge(clk0))then
if(cout0="1001")then
cout0<="0000";m0<='1';
else
cout0<=cout0+'1';m0<='0';
endif;
endif;
endif;
endprocessp1;
p2:
process(clr,m0)
begin
if(set="00"orset="01")then
if(clr='1')then
cout1<="0000";m1<='0';
elsif(rising_edge(m0))then
if(cout1="0101")then
cout1<="0000";m1<='1';
else
cout1<=cout1+'1';m1<='0';
endif;
endif;
elsif(set="10")then
if(clk0='1')then
m1<='1';
else
m1<='0';
endif;
endif;
endprocessp2;
p3:
process(clr,m1)
begin
if(set="00"orset="10")then
if(clr='1')then
cout2<="0000";m2<='0';
elsif(rising_edge(m1))then
if(cout2="1001")then
cout2<="0000";m2<='1';
else
cout2<=cout2+'1';m2<='0';
endif;
endif;
endif;
endprocessp3;
p4:
process(clr,m2)
begin
if(set="00"orset="10")then
if(clr='1')then
cout3<="0000";m3<='0';
elsif(rising_edge(m2))then
if(cout3="0101")then
cout3<="0000";m3<='1';
else
cout3<=cout3+'1';m3<='0';
endif;
endif;
elsif(set="11")then
if(clk0='1')then
m3<='1';
else
m3<='0';
endif;
endif;
endprocessp4;
p5:
process(clr,m3)
begin
if(set="00"orset="11")then
if(clr='1')then
cout4<="0000";m4<='0';
elsif(rising_edge(m3))then
if(cout4="1001")then
cout4<="0000";m4<='1';
elsif(cout5="0010"andcout4="0011")then
cout4<="0000";m4<='1';
else
cout4<=cout4+'1';m4<='0';
endif;
endif;
endif;
endprocessp5;
p6:
process(clr,m4)
begin
if(set="00"orset="11")then
if(clr='1')then
cout5<="0000";
elsif(rising_edge(m4))then
if(cout5="0010"andcout4="0011")then
cout5<="0000";
else
cout5<=cout5+'1';
endif;
endif;
endif;
endprocessp6;
p7:
process(clk0,clear)
begin
if(rising_edge(clk0))then
if(cout5>="0010"andcout4="0011"andcout3="0101"andcout2="1001"andcout1="0101"andcout0="1001")then
clr<='1';
else
clr<='0';
endif;
endif;
if(clear='1')then
clr<='1';
else
clr<='0';
endif;
endprocessp7;
output:
process(m0,m1,m2,m3,m4)
begin
second0<=cout0;
second1<=cout1;
minute0<=cout2;
minute1<=cout3;
hour0<=cout4;
hour1<=cout5;
endprocessoutput;
endarch;
2.2编译(Compilation)
EP1K30TC144-3引脚与插孔对照表
插孔号
引脚号
插孔号
引脚号
插孔号
引脚号
3
125(时钟)
33
55(时钟)
60
100
4
126(input)
34
56(input)
5
128
35
59
62
92
6
130
36
60
63
95
7
131
37
62
8
132
38
63
66
96
9
133
39
64
10
135
40
65
68
101
11
136
41
67
69
102
12
137
70
109
13
138
45
68
71
110
14
140
46
69
72
111
15
141
47
70
73
112
16
142
48
72
74
113
17
143
49
73
75
114
18
144
50
78
76
116
51
79
77
117
20
91
52
80
78
118
53
81
79
119
27
44
54
82
80
120
28
46
55
83
81
121
29
47
56
86
82
122
30
48
57
87
83
124(input)
31
49
58
88
32
51
59
99
五个输入为6,7,8,9,10对应引脚如表,输出为六个分别为11,12,14,35,36,37对应引脚如表。
在按照图示及引脚和插孔对照表插线后,出现“cannotconfigurethedevice....”“connotsimulation”。
是因为设备的问题,换设备之后成功。
2.3下载(Programming)
前几次出现无法下载至机器的状况,后发现为设备原因,换了一台机器之后下载成功。
2.4验证
验证结果,与预期一致。
3设计总结
本次试验一方面需要我们掌握数字逻辑电路的知识,另一方面又要适应新的软件QuartusⅡ和试验箱的用法。
虽说和电工电子实验的内容基本一样,但用的方法却不一样。
上次实验除了理论知识外,还需要相当好的运气,如果哪边没接地或哪个孔差错了可能需要你花掉很长的时间去查错,而且如果是芯片坏了会更加的麻烦,效率比较低,看的眼花缭乱。
而这一次,可以利用软件仿真,观察波形,调试,而且不会发生芯片烧坏的情况。
当然,本次试验中我也遇到不少新的问题。
在程序设计的过程中,我经常会遇到一些错误,但一般错误都是能自己改正的,遇到最多的错误就是输入、输出忘标了,主要还是不够细致造成的。
当然也有许多问题是自己不能解决的,这时就要请教老师,或跟同组的商量。
对于本次实验,我深刻的体会到:
作为学生,我们要学好专业知识和技能,这样在用到时才能得心应手;要有自学新知识的能力,对于陌生的东西要根据已掌握的知识来帮助自己尽快了解它;遇到困难时,首先要自己想办法解决,实在解决不了时就要向老师和同学请教,此外,团队合作也是成功的关键。
最后,再次感谢在本次试验中帮助过我的同学和老师!
4结束语
首先感谢老师一年的细心教导,没有老师的细心教导我们肯定学不到这么多的知识。
然后感谢我们班上的董亮,如果有程序上的问题去问他,他都会一一的详细解答。
最后感谢实验室里面不知道叫什么的那个同学,在下载和设备有疑问的时候,给予了我解答。
谢谢你们!
附录1参考文献
[1]朱勇.数字逻辑.北京:
中国铁道出版社.2005,7.
[2]北京理工大学ASIC研究所.VHDL语言100例详解[M].北京:
清华大学出版社,1999