eda数字钟课程设计.docx

上传人:b****7 文档编号:11297931 上传时间:2023-02-26 格式:DOCX 页数:17 大小:167.17KB
下载 相关 举报
eda数字钟课程设计.docx_第1页
第1页 / 共17页
eda数字钟课程设计.docx_第2页
第2页 / 共17页
eda数字钟课程设计.docx_第3页
第3页 / 共17页
eda数字钟课程设计.docx_第4页
第4页 / 共17页
eda数字钟课程设计.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

eda数字钟课程设计.docx

《eda数字钟课程设计.docx》由会员分享,可在线阅读,更多相关《eda数字钟课程设计.docx(17页珍藏版)》请在冰豆网上搜索。

eda数字钟课程设计.docx

eda数字钟课程设计

EDA应用技术

题目:

VHDL数字时钟设计

系部:

机电工程系

班级:

08电信(3)班

姓名:

学号:

指导老师:

 

VHDL数字时钟设计

一、设计分析

1、功能介绍

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

(2)时钟计数显示时有LED灯的花样显示。

(3)具有调节小时、分钟及清零的功能。

(4)具有整点报时功能。

2、总体方框图

3、性能指标及功能设计

1)时钟计数:

完成时、分、秒的正确计时并且显示所计的数字;对秒、分

——60进制计数,即从0到59循环计数,时钟——24进制计数,即从0到23循环计数,并且在数码管上显示数值。

2)时间设置:

手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。

我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1HZ的,所以每LED灯变化一次就来一个脉冲,即计数一次。

3)清零功能:

reset为复位键,低电平时实现清零功能,高电平时正常计数。

可以根据我们自己任意时间的复位。

4)蜂鸣器在整点时有报时信号产生,蜂鸣器报警。

产生“滴答.滴答”的报警声音。

5)LED灯在时钟显示时有花样显示信号产生。

即根据进位情况,LED不停的闪烁,从而产生“花样”信号。

二、选择方案

1、方案选择

根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。

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

显示:

小时采用24进制,而分钟和秒均60进制。

三、细化框图

根据自顶向下的方法以及各功能模块的的功能实现上述设计方案应系统细化框图:

四、编写程序、仿真和分析

1、秒计数器

1)VHDL语言描述程序见附录

2)秒计数器的仿真波形图

3)波形分析

利用60进制计数器完成00到59的循环计数功能,当秒计数至59时,再来一个时钟脉冲则产生进位输出,即enmin=1;reset作为复位信号低电平有效,即高电平时正常循环计数,低电平清零。

因为这种60进制的VHDL语言是很好写的,它并不复杂,再说我们必须要学会这些基本的硬件语言的描写。

2、分钟计数器

1)VHDL语言描述程序见附录

2)分钟计数器的仿真波形图

3)波形分析

小时计数模块利用24进制计数器,通过分钟的进位信号的输入可实现从00到23的循环计数。

3、小时计数器

1)VHDL语言描述程序见附录

2)小时计数器的仿真波形图

3)波形分析

小时计数模块利用24进制计数器,通过分钟的进位信号的输入可实现从00到23的循环计数。

4、整点报时报警模块

1)VHDL语言描述程序见附录

2)整点报时模块仿真波形图

1)波形分析

由图知对于整点报时模块,当分钟计数至59时来一个时钟脉冲则产生一个进位信号,分钟计数到00,此时产生报警信号持续一分钟。

当有时钟脉冲时lamp显示灯就闪烁轮续点亮。

五、全系统联调

1、数字时钟系统原理图

2、数字时钟系统波形图仿真

六、实验步骤及实验现象

1、七启动MaxplusⅡ10.2软件,打开工程Test26/time文件,下载time.sof程序。

2、将8位拨码开关CTRL的

(1)

(2)(4)(8)设置为“ON”,短接SK2。

3、计数频率CLK接TJ1频率段的1Hz档;扫描频率CKDSP接TJ8频率段的32768Hz档;报时频率CLKSPK接TJ5的1024Hz档。

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秒开始依次闪烁

七、附录(源程序)

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;

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;

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;

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;

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;

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;

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

当前位置:首页 > 高等教育 > 历史学

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

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