EDA数字钟.docx
《EDA数字钟.docx》由会员分享,可在线阅读,更多相关《EDA数字钟.docx(17页珍藏版)》请在冰点文库上搜索。
EDA数字钟
EDA课程设计报告
题目:
数字钟设计
院系:
电子工程学院
专业:
电子信息工程技术
班级:
B0912
姓名:
徐超
学号:
20911060209
指导老师:
高玉宝
2011年12月
一、设计分析
1、功能介绍
1.1具有时、分、秒计数显示功能,以24小时循环计时。
1.2时钟计数显示时有LED灯的花样显示。
1.3具有调节小时、分钟及清零的功能。
1.4具有整点报时功能。
2、总体方框图
3、性能指标及功能设计
3.1时钟计数:
完成时、分、秒的正确计时并且显示所计的数字;对秒、分
——60进制计数,即从0到59循环计数,时钟——24进制计数,即从0到23循环计数,并且在数码管上显示数值。
3.2置:
手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。
我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1HZ的,所以每LED灯变化一次就来一个脉冲,即计数一次。
3.3功能:
reset为复位键,低电平时实现清零功能,高电平时正常计数。
可以根据我们自己任意时间的复位。
3.4在整点时有报时信号产生,蜂鸣器报警。
产生“滴答.滴答”的报警声音。
3.5灯在时钟显示时有花样显示信号产生。
即根据进位情况,LED不停的闪烁,从而产生“花样”信号。
二、选择方案
1.1方案选择
根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。
采用自顶向下的设计方法,子模块利用VHDL语言设计,顶层文件用原理图的设计方法。
显示:
小时采用24进制,而分钟和秒均60进制。
三、细化框图
1.1根据自顶向下的方法以及各功能模块的的功能实现上述设计方案应系统细化框图:
四、编写程序、仿真和分析
4.1秒计数器
1)VHDL语言言描述程序见附录
2)秒计数器的仿真波形图
3)波形分析
利用60进制计数器完成00到59的循环计数功能,当秒计数至59时,再来一个时钟脉冲则产生进位输出,即enmin=1;reset作为复位信号低电平有效,即高电平时正常循环计数,低电平清零。
因为这种60进制的VHDL语言是很好写的,它并不复杂,再说我们必须要学会这些基本的硬件语言的描写。
4.2分钟计数器
1)VHDL语言描述程序见附录
2)分钟计数器的仿真波形图
3)波形分析
小时计数模块利用24进制计数器,通过分钟的进位信号的输入可实现从00到23的循环计数。
4.3小时计数器
1)VHDL语言描述程序见附录
2)小时计数器的仿真波形图
3)波形分析
小时计数模块利用24进制计数器,通过分钟的进位信号的输入可实现从00到23的循环计数。
4.4整点报时报警模块
1)VHDL语言描述程序见附录
2)整点报时模块仿真波形图
3)波形分析
由图知对于整点报时模块,当分钟计数至59时来一个时钟脉冲则产生一个进位信号,分钟计数到00,此时产生报警信号持续一分钟。
当有时钟脉冲时lamp显示灯就闪烁轮续点亮。
五、全系统联调
5.1数字时钟系统原理图
5.2数字时钟系统波形图仿真
六、实验步骤及实验现象
6.1启动MaxplusⅡ10.2软件,打开工程Test26/time文件,下载time.sof程序。
6.2将8位拨码开关CTRL的
(1)
(2)(4)(8)设置为“ON”,短接SK2。
6.3计数频率CLK接TJ1频率段的1Hz档;扫描频率CKDSP接TJ8频率段的32768Hz档;报时频率CLKSPK接TJ5的1024Hz档。
6.4按键K1为清零信号RESET(高电平有效),按键K2代表调节小时,按键K3代表调节分钟;数码管SM6~SM1显示具体的时间;发光二极管LED1~LED9分别代表程序中的LAMP0~LAMP8信号;当程序下载完毕后数码管从00时00分00秒开始计时,通过按键K3可以调节时钟的分钟显示,通过按键K2可以调节时钟的小时显示(调节时钟时应将按键所对应的拨位开关KD2和KD3拨向下;拨位开关KD2和KD3拨向上时,数字钟正常计时)。
当时钟走到XX时59分51秒时,喇叭开始鸣叫,其中51秒、53秒、55秒、57秒为低音,59秒为高音,发光二极管LED1~LED9从51秒开始依次闪烁
七、附录(源程序)
7.1小时计数器VHDL语言源程序(底层文件)
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityhouris
port(reset,clk:
instd_logic;
daout:
outstd_logic_vector(7downto0));
endhour;
architecturebehavofhouris
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<2)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
else
if(count=3)then
count<="0000";
counter<="0000";
else
count<=count+1;
endif;
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
endbehav;
7.2分钟计数器VHDL语言源程序(底层文件)
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityminuteis
port(reset,clk,sethour:
instd_logic;
daout:
outstd_logic_vector(7downto0);
enhour:
outstd_logic);
endminute;
architecturebehavofminuteis
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
signalcarry_out1:
std_logic;
signalcarry_out2:
std_logic;
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<5)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
carry_out1<='0';
else
if(count=9)then
count<="0000";
counter<="0000";
carry_out1<='1';
else
count<=count+1;
carry_out1<='0';
endif;
endif;
endif;
endprocess;
p2:
process(clk)
begin
if(clk'eventandclk='0')then
if(counter=0)then
if(count=0)then
carry_out2<='0';
endif;
else
carry_out2<='1';
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
enhour<=(carry_out1andcarry_out2)orsethour;
endbehav;
7.3秒钟计数器VHDL语言源程序(底层文件)
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitysecondis
port(reset,clk,setmin:
instd_logic;
daout:
outstd_logic_vector(7downto0);
enmin:
outstd_logic);
endsecond;
architecturebehavofsecondis
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
signalcarry_out1:
std_logic;
signalcarry_out2:
std_logic;
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<5)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
carry_out1<='0';
else
if(count=9)then
count<="0000";
counter<="0000";
carry_out1<='1';
else
count<=count+1;
carry_out1<='0';
endif;
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
enmin<=carry_out1orsetmin;
endbehav;
7.4整点报时报警模块VHDL语言源程序(底层文件)
LibraryIEEE;
useIEEE.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityalertis
Port(
clkspk:
instd_logic;
second:
instd_logic_vector(7downto0);
minute:
instd_logic_vector(7downto0);
speak:
outstd_logic;
lamp:
outstd_logic_vector(8downto0));
endalert;
architecturebehavofalertis
signaldivclkspk2:
std_logic;
begin
p1:
process(clkspk)
begin
if(clkspk'eventandclkspk='1')then
divclkspk2<=notdivclkspk2;
endif;
endprocess;
p2:
process(second,minute)
begin
if(minute="01011001")then
casesecondis
when"01010001"=>lamp<="000000001";speak<=divclkspk2;
when"01010010"=>lamp<="000000010";speak<='0';
when"01010011"=>lamp<="000000100";speak<=divclkspk2;
when"01010100"=>lamp<="000001000";speak<='0';
when"01010101"=>lamp<="000010000";speak<=divclkspk2;
when"01010110"=>lamp<="000100000";speak<='0';
when"01010111"=>lamp<="001000000";speak<=divclkspk2;
when"01011000"=>lamp<="010000000";speak<='0';
when"01011001"=>lamp<="100000000";speak<=clkspk;
whenothers=>lamp<="000000000";
endcase;
endif;
endprocess;
endbehav;
7.5显示模块VHDL语言源程序(底层文件)
LIBRARYIEEE;
USEIEEE.STD_LOGIC_1164.ALL;
ENTITYDELEDIS
PORT(
S:
INSTD_LOGIC_VECTOR(3DOWNTO0);
A,B,C,D,E,F,G,H:
OUTSTD_LOGIC);
ENDDELED;
ARCHITECTUREBEHAVOFDELEDIS
SIGNALDATA:
STD_LOGIC_VECTOR(3DOWNTO0);
SIGNALDOUT:
STD_LOGIC_VECTOR(7DOWNTO0);
BEGIN
DATA<=S;
PROCESS(DATA)
BEGIN
CASEDATAIS
WHEN"0000"=>DOUT<="00111111";
WHEN"0001"=>DOUT<="00000110";
WHEN"0010"=>DOUT<="01011011";
WHEN"0011"=>DOUT<="01001111";
WHEN"0100"=>DOUT<="01100110";
WHEN"0101"=>DOUT<="01101101";
WHEN"0110"=>DOUT<="01111101";
WHEN"0111"=>DOUT<="00000111";
WHEN"1000"=>DOUT<="01111111";
WHEN"1001"=>DOUT<="01101111";
WHEN"1010"=>DOUT<="01110111";
WHEN"1011"=>DOUT<="01111100";
WHEN"1100"=>DOUT<="00111001";
WHEN"1101"=>DOUT<="01011110";
WHEN"1110"=>DOUT<="01111001";
WHEN"1111"=>DOUT<="01000000";
WHENOTHERS=>DOUT<="00000000";
ENDCASE;
ENDPROCESS;
H<=DOUT(7);
G<=DOUT(6);
F<=DOUT(5);
E<=DOUT(4);
D<=DOUT(3);
C<=DOUT
(2);
B<=DOUT
(1);
A<=DOUT(0);
ENDBEHAV;
7.6控制调时模块VHDL语言源程序(底层文件)
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityseltimeis
port(
ckdsp:
instd_logic;
reset:
instd_logic;
second:
instd_logic_vector(7downto0);
minute:
instd_logic_vector(7downto0);
hour:
instd_logic_vector(7downto0);
daout:
outstd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0));
endseltime;
architecturebehavofseltimeis
signalsec:
std_logic_vector(2downto0);
begin
process(reset,ckdsp)
begin
if(reset='0')then
sec<="000";
elsif(ckdsp'eventandckdsp='1')then
if(sec="111")then
sec<="000";
else
sec<=sec+1;
endif;
endif;
endprocess;
process(sec,second,minute,hour)
begin
casesecis
when"000"=>daout<=second(3downto0);
when"001"=>daout<=second(7downto4);
when"011"=>daout<=minute(3downto0);
when"100"=>daout<=minute(7downto4);
when"110"=>daout<=hour(3downto0);
when"111"=>daout<=hour(7downto4);
whenothers=>daout<="1111";
endcase;
endprocess;
sel<=sec;
endbehav;
八、实习心得
8.1经过一个星期对实践的制作,从中学到了很多。
首先是对EDA的vhd语言的更深层次认识,本来觉得EDA编程语言比较麻烦,可是接触了以后也就觉得它还是有它方便的地方,尤其是和图形编程结合的特点。
其次,这个实践其实到目前为止应该还不是一个成功的作品,还是有很多的仿真没有完成,结果也不是很理想,原因可能也是自己的技术不到位,对EDA还不是很熟练。
但是整个制作的过程中,它促进了同学之间的相互沟通,也让我在自己的专业知识的学习过程中,更多的,更好的学习一门知识,用于以后的实践应用中,做这个数字钟的设计中包含了很多不同功能的程序,让我在其中学到了一些程序的中的思路,特别一步一步去把错误的程序改正确是一种很有成就感的事!
这样让我学到了更多的知识!
特别是在做24进制的时候,我在网上查了好多程序,证实了好多错误的程序并从中更改出正确的程序!
相信,现在只是一个起步,以后,我会更好的努力,学习,对EDA孰能生巧。
.