vhd 数字中设计.docx

上传人:b****3 文档编号:3806271 上传时间:2022-11-25 格式:DOCX 页数:15 大小:249.03KB
下载 相关 举报
vhd 数字中设计.docx_第1页
第1页 / 共15页
vhd 数字中设计.docx_第2页
第2页 / 共15页
vhd 数字中设计.docx_第3页
第3页 / 共15页
vhd 数字中设计.docx_第4页
第4页 / 共15页
vhd 数字中设计.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

vhd 数字中设计.docx

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

vhd 数字中设计.docx

vhd数字中设计

一、实验目的

1.学习数字系统设计的自顶向下设计法及控制器的设计。

2.加深利用EDA技术实现数字系统的体会。

二、实验仪器及器件

1.EDA开发软件(1套)2.微机(1台)

3.实验开发系统(1台)4.其他器件与材料(若干)

三、实验要求及设计方案

1.设计一个具有24进制计时、显示、整点报时、时间设置和闹钟功能的数字钟,要求时钟的最小分辨率时间为1s。

2.数字钟的设计方案如下:

系统输入:

mode为计时显示和闹钟定时显示转换输入;set为校时和定时设置的时、分、秒转换输入;k为校时和定时设置的时、分、秒手动加1输入;clk为时钟信号;reset为系统复位信号。

输入信号均由按键产生。

系统输出:

LED显示输出;蜂鸣器(bell)声音信号输出。

3.多功能数字钟系统功能的具体描述如下:

计时:

正常工作状态下,每日按24小时计时制计时并显示,蜂鸣器逢整点报时。

校时:

在计时显示状态下,按下“set键”,进入“小时”校时状态,再次按下“set键”,进入“分”校时状态,继续按下“set键”,进入“秒”校时状态,第四次按下“set键”又回复到正常计时显示状态。

1)“小时”校时状态:

进入“小时”校时状态后,显示“小时”的数码管闪烁,每按动“k”键一次,“小时”+1,若不按动“k”键则小时数不变,一直按下“k”键则小时数一4Hz的频率递增计数。

2)“分”校时状态:

进入“分”校时状态后,显示“分”的数码管闪烁,每按动“k”键一次,“分”+1,若不按动“k”键则分数不变,一直按下“k”键则分数一4Hz的频率递增计数。

3)“秒”校时状态:

进入“秒”校时状态后,显示“秒”的数码管闪烁,每按动“k”键一次,“秒”+1,若不按动“k”键则秒数不变,一直按下“k”键则秒数一4Hz的频率递增计数。

整点报时:

蜂鸣器在“59”分钟的第51、53、55、57秒发出频率为512Hz的低音,在“59”秒发出频率为1024Hz的高音,结束时为整点。

显示:

采用8个LED数码管分别显示时、分、秒并且他们之间用“—”隔开。

闹钟:

闹钟定时时间到,蜂鸣器发出周期为1s的滴、滴声,持续时间为10秒;闹钟定时显示。

闹钟定时设置:

在闹钟显示状态下,按下“set键”,进入“小时”校时状态,再次按下“set键”,进入“分”校时状态,继续按下“set键”,进入“秒”校时状态,第四次按下“set键”又回复到闹钟显示状态。

闹钟的时、分、秒设置过程和计时设置相同。

计时显示和闹钟显示之间的转换:

按动“mode”键,数字钟将在计时显示和闹钟定时显示之间转换。

4)多功能数字钟系统结构逻辑框图如下:

mode

5)控制器的MDS图如下:

set=0

 

四、各功能模块的源程序代码:

--CONTOR模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entitycontoris

port(clk,k,set,reset,mode:

instd_logic;

chs,cht,cms,cmt,css,cst,flashh,flashm,flashs,sel_show:

outstd_logic);

endcontor;

architecturecontor_archofcontoris

typestatesis(s0,s1,s2,s3,s4,s5,s6,s7);

signalcurrent_state,next_state:

states;

begin

process(reset,clk,next_state)

begin

if(reset='1')then

current_state<=s0;

elsif(clk'eventandclk='1')then

current_state<=next_state;

endif;

endprocess;

process(current_state,k,set)

begin

casecurrent_stateis

whens0=>

flashh<='0';flashm<='0';flashs<='0';cht<='0';cmt<='0';cst<='0';chs<='0';cms<='0';css<='0';sel_show<='1';

if(mode='0')thennext_state<=s4;

elsif(k='1'andset='0')then

next_state<=s1;

else

next_state<=s0;

endif;

whens1=>

flashh<='1';flashm<='0';flashs<='0';cht<='1';cmt<='0';cst<='0';chs<='0';cms<='0';css<='0';sel_show<='1';

if(set='0')then

next_state<=s2;

else

next_state<=s1;

endif;

whens2=>

flashh<='0';flashm<='1';flashs<='0';cht<='0';cmt<='1';cst<='0';chs<='0';cms<='0';css<='0';sel_show<='1';

if(set='0')then

next_state<=s3;

else

next_state<=s2;

endif;

whens3=>

flashh<='0';flashm<='0';flashs<='1';cht<='0';cmt<='0';cst<='1';chs<='0';cms<='0';css<='0';sel_show<='1';

if(set='0')then

next_state<=s0;

else

next_state<=s3;

endif;

whens4=>

flashh<='0';flashm<='0';flashs<='0';cht<='0';cmt<='0';cst<='0';

chs<='0';cms<='0';css<='0';sel_show<='0';

if(mode='0')then

next_state<=s0;

elsif(k='1'andset='0')then

next_state<=s5;

else

next_state<=s4;

endif;

whens5=>

flashh<='1';flashm<='0';flashs<='0';cht<='0';cmt<='0';cst<='0';

chs<='1';cms<='0';css<='0';sel_show<='0';

if(set='0')then

next_state<=s6;

else

next_state<=s5;

endif;

whens6=>

flashh<='0';flashm<='1';flashs<='0';cht<='0';cmt<='0';

cst<='0';chs<='0';cms<='1';css<='0';sel_show<='0';

if(set='0')then

next_state<=s7;

else

next_state<=s6;

endif;

whens7=>

flashh<='0';flashm<='0';flashs<='1';cht<='0';cmt<='0';

cst<='0';chs<='0';cms<='0';css<='1';sel_show<='0';

If(set='0')then

next_state<=s4;

else

next_state<=s7;

endif;

endcase;

endprocess;

endcontor_arch;

--*********************TIMER模块********************

 

--*************cnt60模块*****

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitycnt60is

port(clkin:

instd_logic;

mh,ml:

bufferstd_logic_vector(3downto0);

co:

bufferstd_logic);

endminute;

architecturecnt60xofminutecnt60is

begin

process(clkin)

begin

if(rising_edge(clkin))then

if(mh="0101"andml="1001")then

mh<="0000";co<='1';ml<="0000";

elsif(ml="1001")then

ml<="0000";mh<=mh+1;co<='0';

elseml<=ml+1;co<='0';

endif;

endif;

endprocess;

endcnt60x;

--********MUX2-1模块********

libraryieee;

useieee.std_logic_1164.all;

entitymux2_1is

port(d0,d1,en:

instd_logic;

sel:

instd_logic;

y:

outstd_logic);

endmux2_1;

architecturemux2_1_archofmux2_1is

begin

process(d0,d1,sel)

begin

if(sel='0')then

y<=d0;

elsif(sel='1'anden='0')then

y<=d1;

endif;

endprocess;

endmux2_1_arch;

 

――*****************Time_com模块*********

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitytime_comis

port(hh,mh,sh,hl,ml,k:

instd_logic_vector(3downto0);

chs,cms,css,f4:

instd_logic;

bsg,bmg,bhg,bsd,bmd,bhd:

bufferstd_logic_vector(3downto0);

comout:

outstd_logic);

endtime_com;

architecturetime_comxoftime_comis

begin

com:

process(hh,mh,sh,hl,ml)

begin

if(bhg=hhandbhd=hlandbmg=mhandbmd=mlandbsg=sh)then

comout<='1';

else

comout<='0';

endif;

endprocess;

set:

process(f4)

begin

if(f4'eventandf4='1')then

if(chs='1'andk='0')then

if(bhg="0010"andbhd="0011")then

bhd<="0000";bhg<="0000";

elsif(bhd="1001")then

bhd<="0000";bhg<=bhg+1;

elsif(bhd="0000"orbhd="0001"orbhd="0010"or

bhd="0011"orbhd="0100"orbhd="0101"orbhd="0110"or

bhd="0111"orbhd="1000")then

bhd<=bhd+1;

endif;

endif;

endif;

endprocess;

process(f4)

begin

if(f4'eventandf4='1')then

if(cms='1'andk='0')then

if(bmg="0101"andbmd="1001")then

bmd<="0000";bmg<="0000";

elsif(bmd="1001")then

bmd<="0000";bmg<=bmg+1;

elsif(bmd="0000"orbmd="0001"orbmd="0010"or

bmd="0011"orbmd="0100"orbmd="0101"orbmd="0110"or

bmd="0111"orbmd="1000")then

bmd<=bmd+1;

endif;

endif;

endif;

endprocess;

process(f4)

begin

if(f4'eventandf4='1')then

if(css='1'andk='0')then

if(bsg="0101"andbsd="1001")then

bsd<="0000";bsg<="0000";

elsif(bsd="1001")then

bsd<="0000";bsg<=bsg+1;

elsif(bsd="0000"orbsd="0001"orbsd="0010"or

bsd="0011"orbsd="0100"orbsd="0101"orbsd="0110"or

bsd="0111"orbsd="1000")then

bsd<=bsd+1;

endif;

endif;

endif;

endprocess;

endtime_comx;

--*****************Show_contor模块****************************

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityshow_contoris

port(hh,mh,sh,bhh,bmh,bsh,hl,ml,sl,bhl,bml,bsl:

instd_logic_vector(3downto0);

flashh,flashm,flashs,clk1,sel_show:

instd_logic;

sld0,shd1,mld3,mhd4,hld6,hhd7,line:

outstd_logic_vector(3downto0));

endshow_contor;

architectureshow_contor_archofshow_contoris

begin

line<="1010";

process(clk1)

begin

ifsel_show='1'then

sld0<=sl;

shd1<=sh;

mld3<=ml;

mhd4<=mh;

hld6<=hl;

hhd7<=hh;

elsifsel_show='0'then

sld0<=bsl;

shd1<=bsh;

mld3<=bml;

mhd4<=bmh;

hld6<=bhl;

hhd7<=bhh;

endif;

if(clk1='1'andflashs='1')then

sld0<="1111";shd1<="1111";

endif;

if(clk1='1'andflashm='1')then

mld3<="1111";mhd4<="1111";

endif;

if(clk1='1'andflashh='1')then

hld6<="1111";hhd7<="1111";

endif;

endprocess;

endshow_contor_arch;

--****************Dynamic_show模块代码(略)*********************

--*************Bell模块********************************************

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitybelis

port(mh,sh,ml,sl:

instd_logic_vector(3downto0);

comout,f512hz,f1024hz,clk:

instd_logic;

bell:

outstd_logic);

endbel;

architecturebel_archofbelis

begin

process(clk,mh,ml,sh,sl,f1024hz,f512hz)

begin

if(comout='1')then

bell<=clk;

elsif(mh="0101"andml="1001")then

if(sh="0101")then

if(sl="1001")then

bell<=f1024hz;

elsif(sl="0001"orsl="0011"orsl="0101"orsl="0111")then

bell<=f512hz;

endif;

else

bell<='0';

endif;

elsif(ml<"1001"ormh<"0101"orsh<"0101")then

bell<='0';

endif;

endprocess;

endbel_arch;

五、连接总图(如右):

六、波形仿真:

七、引脚锁定、编译、连线并下载到实验箱进行验证

121416111150151152153154155156787980183182

sel0sel1sel2belly0y1y2y3y4y5y6modesetkreset1reset2

八、心得体会

为期一周的课程设计在紧张与忙碌中飞逝而过,我所选择的多功能电子钟在老师孜孜不倦的指导下和同学的热心帮助下终于成功了。

不但实现了题目所要求的全部功能,还实现了更人性化的功能(按一下按键执行一次加1操作)。

这一功能的实现是在x老师的启发和指导以及在xxx同学的帮助与提问下才得以实现的。

刚开始按照老师的思路虽然实现了按一下按键执行一次加1的功能,当时我以为自己成功了,可她发现秒钟到59后没有产生进位信号,分位没有加1。

在她发现错误后,我仔细研究了产生这种错误的原因,原来我把控制校时的使能信号输入端放在了计数器里边,它屏蔽了进位信号。

最后,我把控制校时的使能信号放在了mux2_1终于解决了不进位的错误。

通过这件事使我认识到与同学的讨论是十分有必要和重要的。

在与同学的讨论中不但使我发现了自己的错误和不足,还使自己开阔了眼界,增长了见识,增进了同学之间的友谊。

课程设计全方位的培养和考察我们解决问题以及处理将理论应用到实际当中的能力。

在设计编程的过程中,我们既经过了独立思考,也经过了团体协作。

我们必须在短期内锻炼迅速掌握一门语言的能力,并学会利用其他的资料与书籍。

可见课程设计的意义是十分重大和深远的。

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

当前位置:首页 > 工程科技 > 能源化工

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

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