数字电路与EDA电子时钟.docx

上传人:b****6 文档编号:7956149 上传时间:2023-01-27 格式:DOCX 页数:11 大小:58.43KB
下载 相关 举报
数字电路与EDA电子时钟.docx_第1页
第1页 / 共11页
数字电路与EDA电子时钟.docx_第2页
第2页 / 共11页
数字电路与EDA电子时钟.docx_第3页
第3页 / 共11页
数字电路与EDA电子时钟.docx_第4页
第4页 / 共11页
数字电路与EDA电子时钟.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

数字电路与EDA电子时钟.docx

《数字电路与EDA电子时钟.docx》由会员分享,可在线阅读,更多相关《数字电路与EDA电子时钟.docx(11页珍藏版)》请在冰豆网上搜索。

数字电路与EDA电子时钟.docx

数字电路与EDA电子时钟

《数字电路与EDA》

课程设计报告

设计题目:

数字电子钟

专业:

班级:

姓名:

学号:

指导教师:

时间:

2011年12月

 

目录

 

1、设计目的和要求...........................3

2、设计任务.....................................3

3、方案论证与比较...............................3

4、设计原理和VHDL................................3

5、硬件测试.......................................9

6、设计小结.......................................10

7、参考文献.......................................10

 

一、设计目的和要求

1、对所有设计的系统能够正确分析;

2、基于VHDL语言描述系统的功能;

3、在quartus2环境中编译通过;

4、下载到EDA实验箱进行验证;

5、给出相应的设计报告。

二、设计任务

1)具有时、分、秒计数显示功能,以24小时循环计时。

2)具有调节小时、分钟和秒及清零的功能。

3)具有整点报时功能。

三、方案论证与比较

方案一:

本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。

采用自顶向下的设计方法,子模块利用VHDL语言设计,顶层文件用原理图的设计方法。

用“小时—分”方式显示并且‘—’每秒闪烁,用两个时钟信号。

方案二:

根据总体方框图及各部分分配的功能可知,本系统可以由分频器、秒计数器、分钟计数器、小时计数器、整点报时、分的调整、秒的调整以及小时的调整,模块利用VHDL语言设计。

用“小时—分—秒”方式显示并只用一个时钟。

终上所述,考虑到试验时的全面,故我选择了方案二。

四、设计原理和VHDL:

A设计原理和思路

该系统由振荡器、分频器、“时、分、秒”计数器、译码器及显示器、校时电路、整点报时电路等组成。

石英晶体振荡器和分频器产生整个系统的时钟信号,它直接决定计时系统的精度。

“秒计数器”采用六十进制计数器,每累计60秒向“分计数器”进位;“分计数器”采用六十进制计数器,每累计60分向“时计数器”进位;“时计数器”采用二十四进制计数器,按照“24翻1”规律计数。

“时、分、秒”计数器的输出经译码器送显示器显示。

校时电路用来当计时出现误差时对“时、分、秒”进行校对调整。

整点报时电路是根据计时系统的输出状态产生一脉冲信号,然后去触发彩灯实现报时。

B、VHDL

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entityffis

port(clk,reset,S1,S2:

instd_logic;

alarm:

outstd_logic;

cba:

outstd_logic_vector(2downto0);

seg:

outstd_logic_vector(6downto0);

q:

outstd_logic_vector(7downto0));

end;

architectureoneofffis

signalsec1,sec2,min1,min2,hou1,hou2,data,ss:

std_logic_vector(3downto0);

signalensec,enmin,c,tmp_hou,tmp_min,alarm1,key_out,tmp_sec:

std_logic;

signalcnt:

integerrange0to511:

=0;

signalclks:

std_logic:

='0';

signalcnt1:

std_logic_vector(2downto0);

signaltmp1,a,b:

std_logic_vector(7downto0);

signalkey_mode:

std_logic_vector(1downto0);

begin

process(clk,reset)

begin

ifreset='1'then

clks<='0';

elsifrising_edge(clk)then

ifcnt=511then

cnt<=0;

clks<=not(clks);

else

cnt<=cnt+1;

endif;

endif;

endprocess;

process(tmp_sec,reset)

begin

ifreset='1'then

sec1<="0000";

sec2<="0000";

ensec<='0';

elsifrising_edge(tmp_sec)then

if(sec1="1001"andsec2="0101")then

sec1<="0000";

sec2<="0000";

ensec<='1';

elsif(sec1="1001")then

sec1<="0000";

sec2<=sec2+1;

ensec<='0';

else

sec1<=sec1+1;

ensec<='0';

endif;

endif;

endprocess;

process(tmp_min,reset)

begin

ifreset='1'then

min1<="0000";

min2<="0000";

enmin<='0';

elsifrising_edge(tmp_min)then

if(min1="1001"andmin2="0101")then

min1<="0000";

min2<="0000";

enmin<='1';

elsif(min1="1001")then

min1<="0000";

min2<=min2+1;

enmin<='0';

else

min1<=min1+1;

enmin<='0';

endif;

endif;

endprocess;

process(tmp_hou,reset)

begin

ifreset='1'then

hou1<="0000";

hou2<="0000";

elsifrising_edge(tmp_hou)then

if(hou1="0011"andhou2="0010")then

hou1<="0000";

hou2<="0000";

elsif(hou1="1001")then

hou1<="0000";

hou2<=hou2+1;

else

hou1<=hou1+1;

endif;

endif;

endprocess;

process(min1,min2)

begin

ifmin1="0000"andmin2="0000"then

alarm1<='1';

else

alarm1<='0';

endif;

endprocess;

process(clks,alarm1)

begin

ifalarm1='1'then

ifclks='1'then

alarm<='1';

else

alarm<='0';

endif;

elsealarm<='0';

endif;

endprocess;

process(clks,hou1,hou2,min1,min2,tmp1)

begin

ifrising_edge(clks)then

ifhou1="0101"andhou2="0000"andmin1="0000"andmin2="0000"then

iftmp1="11111111"then

tmp1<=(others=>'0');

else

tmp1<='1'&tmp1(7downto1);

endif;

else

tmp1<=(others=>'0');

endif;

endif;

endprocess;

q<=tmp1;

process(clks,clk,b)

begin

ifrising_edge(clk)then

b(7downto0)<=b(6downto0)&S1;

Ifb="11111111"then

c<='1';

Else

c<='0';

endif;

endif;

endprocess;

process(c,reset)

begin

ifreset='1'then

key_mode<="00";

else

ifrising_edge(c)then

key_mode<=key_mode+1;

endif;

endif;

endprocess;

process(key_mode,key_out,clks,tmp_min,ensec,enmin)

begin

casekey_modeis

when"10"=>tmp_min<=key_out;tmp_hou<='0';tmp_sec<='0';

when"11"=>tmp_min<='0';tmp_hou<=key_out;tmp_sec<='0';

when"01"=>tmp_min<='0';tmp_hou<='0';tmp_sec<=key_out;

whenothers=>tmp_min<=ensec;tmp_hou<=enmin;tmp_sec<=clks;

endcase;

endprocess;

process(clk,a)

begin

ifrising_edge(clk)then

a(7downto0)<=a(6downto0)&S2;

Ifa="11111111"then

Key_out<='1';

Else

Key_out<='0';

Endif;

endif;

endprocess;

process(clks,key_mode)

begin

ifkey_mode="00"then

ifclks='1'then

ss<="1011";

else

ss<="1010";

endif;

else

ss<="1011";

endif;

endprocess;

process(clk)

begin

ifrising_edge(clk)then

cnt1<=cnt1+1;

endif;

endprocess;

cba<=cnt1;

process(cnt1,hou2,hou1,min1,min2,ss,sec1,sec2)

begin

casecnt1is

when"111"=>data<=hou2(3downto0);

when"110"=>data<=hou1(3downto0);

when"101"=>data<=ss;

when"100"=>data<=min2(3downto0);

when"011"=>data<=min1(3downto0);

when"010"=>data<=ss;

when"001"=>data<=sec2(3downto0);

when"000"=>data<=sec1(3downto0);

whenothers=>data<="1111";

endcase;

endprocess;

process(data)

begin

casedatais

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

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

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

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

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

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

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

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

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

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

when"1011"=>seg<="1000000";

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

whenothers=>seg<="1110001";

endcase;

endprocess;

end;

五、硬件测试

1、引脚设置

2、配置文件下载

将编译产生的SOF格式配置进FPGA中,打开编程窗和配置文件,将实验系统和并口通信线连接好,打开电源。

在菜单TOOL中选择programmer,单机下载标符start按钮,即进入对目标器件FPGA的配置下载操作。

3、硬件调试

配置文件下载成功后,clock选择1024HZ。

  上电后,秒满59向分进1后又从00开始计数,分满59向小时进1后从00开始计数,小时满24从00开始计数。

按键D111后,计时复位,可以用键D110对小时、分、秒进行模式选择,D109可以重新设置时间数码管显示为设置的新时间。

当到整点时,彩灯闪烁报时一分钟。

六、设计小结

通过这次设计,进一步加深了对EDA的了解,让我对它有了更加深度了了解。

刚开始因为对知识的模棱两可,编写的程序出现很多逻辑和语句上的错误,经过问同学,书上的慢慢的了解错在哪里,再一次加深了映像,也在其中找到了乐趣,才能逐渐完成本次课程设计。

在本次实验中不单单从理论上掌握了很多,同时也加强了对编程的逻辑思维的培养和处理语句能力。

看问题不能只看一面,要多方面考虑,明白了遇到问题要先思考而不是盲目的放弃,而应该分析问题找到出出问题之处,而合理运用所学过的知识巧妙的解决问题。

七、参考文献

《数字电子技术基础》--------科学出版社

《图说VHDL》--------化学工业出版社

《VHDL与数字电路设计》--------科学出版社

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

当前位置:首页 > 工程科技 > 环境科学食品科学

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

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