数电实验数字钟_第1页
数电实验数字钟_第2页
数电实验数字钟_第3页
数电实验数字钟_第4页
数电实验数字钟_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、9.16数字钟数字钟设计是数字电路中的一个典型应用,设计方法很多,现在要介绍的是用CPLD设计数字钟的方法。1 .设计目的掌握各类计数器以及他们相连的设计方法;掌握多个数码管显示的原理与方法;掌握CPLD技术的层次化设计方法;掌握使用VHDL语言的设计思想;对整个系统的设计有一个了解。2 .设计要求(1)能进行正常的时、分、秒计时功能,分别由6个数码管显示24h、60min、60s。(2)按下sa键时,计数器迅速递增,弁按24h循环,计数23h后再回00.(3)按下sb键时,计数器迅速递增,弁按60min循环,计数满59min后再回00,但不向”时”进位。(4)利用扬声器整点报时:到达59&#

2、39;0”时开始报时,在59'50"、52"、54”、56"、58”鸣叫,鸣叫声频为500Hz:到达59'60'时为最后一声整点报时,频率为1kHz。总体框图如图9-76所示。图9-76总体框图3 .模块及模块功能模块MIAN如图9-77所示。该模块为60进制计数器,计时输出为秒的数值。在计时到59时送出进位信号CO,因为硬件有延时,所以模块MIAN在模块变为00时加1,符合实际。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitymiani

3、sport(clk,clr:instd_logic;sec1,sec0:outstd_logic_vector(3downto0);co:outstd_logic);endmian;=i R S?OXEri 工 HNs . . a |din Ik sscl C 3 - -口 1 s££03 H 0 J血 图 9-77 模块 MIANarchitecturemian_arcofmianisbeginprocess(clk,clr)variablecnt1,cnt0:std_logic_vector(3downto0);beginae?=>G3ifclr='1&#

4、39;thencnt1:="0000"cnt0:="0000"elsifclk'eventandclk='1'thenifcnt1="0101"andcnt0="1000"thenco<='1'cnt0:="1001"elsifcnt0<"1001"thencnt0:=cnt0+1;elsecnt0:="0000"ifcnt1<"0101"thencnt1:=cnt1+1;els

5、ecnt1:="0000"co<='0'endif;endif;endif;sec1<=cnt1;sec0<=cntO;endprocess;endmian_arc;模块MINA如图9-78所示。该模块为60进制计数器,计时输出为分的数值。在EN信号有效且时钟到来时,计数器加1。在sb按下时,EN信号有效,计数值以秒的速度增加,从而实现对分钟的设置。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityminaisport(en,clk:ins

6、td_logic;min1,min0:outstd_logic_vector(3downto0);co:outstd_logic);endmina;architecturemin_arcofminaisbeginprocess(clk)variablecnt1,cnt0:std_logic_vector(3downto0);beginifclk'eventandclk='1'thenMINAen minlC3- -0elk minBC 3- . 0 3 co 图 9-78 模块 MINAifen='1'thenifcnt1="0101"

7、;andcntO="1OOO"thenco<='1'cntO:="1OO1"elsifcntO<"1OO1"thencntO:=cntO+1;elsecntO:="OOOO"ifcnt1<"0101"thencnt1:=cnt1+1;elsecnt1:="0000"co<='0'endif;endif;endif;endif;min1<=cntl;minO<=cnt0;endprocess;endmin_ar

8、c;模块HOUR如图9-79所示。该模块为24进制计数器,计时输出为小时的数值。设置功能的原理同MINA模块。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;HOURentityhourisport(en,clk:instd_logic;h1,hO:outstdogic_vector(3downto0);endhour;architecturehour_arcofhourisbegin图9-79模块HOURprocess(clk)variablecnt1,cnt0:std_logic_vector(3d

9、ownto0);beginifclk'eventandclk='1'thenifen='1'thenifcnt0="0011"andcnt1="0010"thencnt0:="0000"cnt1:="0000"elsifcnt0<"1001"thencnt0:=cnt0+1;elsecnt0:="0000"cnt1:=cnt1+1;endif;endif;endif;h1<=cnt1;h0<=cnt0;endproce

10、ss;59min ,秒为 50、52、T'。这两个信号经过逻辑门实现endhour_arc;模块SST如图9-80所示。此模块为整点报时提供控制信号;当SSTE1?3 ? B 0 IT0C Z ! , ? 0 1 H 5 G ?59 . . 0 曰,k.3 ? - 0 Jelk54、56、58时,Q500输出为“1”;秒为00时,Q1K输出报时功能。libraryieee;useieee.std_logic_1164.all;entitysstisport(m1,m0,s1,s0:instd_logic_vector(3downto0);clk:instd_logic;q500,q1k

11、:outstd_logic);endsst;architecturesss_arcofsstisbegin图9-80模块SSTprocess(clk)beginifclk'eventandclk='1'thenifm1="0101"andm0="1001"ands1="0101"thenifs0="0000"ors0="0010"ors0="0100"ors0="0110"ors0="1000"thenq500&

12、lt;='1'elseq500<='0'endif;endif;ifm仁"0000"andm0="0000"ands1="0000"ands0="0000"thenq1k<='1'elseq1k<='0'endif;endif;endprocess;endsssarc;模块BBB如图9-81所示。该模块对应不同的片选信号送出不同的要显示的数据。libraryieee;useieee.std_logic_1164.all;entityb

13、bbisport(sec1,secO,min1,min0,h1,hO:instd_logic_vector(3downto0);sel:instdo gic_vector(3 dow nto 0);BBBgic_vector(2downto0);q:outstdendbbb;architecturebbbarcofbbbisbeginprocess(sel)begincaseseliswhen"101"=>q<=sec0;when"001"=>q<=sec1;when"110"=>q<=min0;w

14、hen"010"=>q<=min1;when"100"=>q<=h0;when"000"=>q<=h1;whenothers=>q<="1111"endcase;endprocess;endbbbarc;模块FEN10如图9-82所示。该模块实现十分频。libraryieee;useieee.std_logic_1164.all;entityfen10isport(clk:instd_logic;q:outstd_logic);endfen10;architectur

15、efen_arcoffen10isbeginprocess(clk)variablecnt:integerrange0to9;beginifclk'eventandclk='1'then包0i一rniniCS0,rni30JIiq30JhlC3-01HOC3-0|selC2-0J图9-81模块BBBFENIO图9-82模块FEN10ifcnt<9thencnt:=cnt+1;q<='0'elsecnt:=0;q<='1'endif;endif;endprocess;endfen_arc;模块SEL如图9-83所示。该模块

16、提供数码管片选信号。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityselisport(clk:instd_logic;q:outstd_logic_vector(2downto0);endsel;architecturesel_arcofselisbeginprocess(clk)SELvariablecnt:std_logic_vector(2downto0);图9-83模块SELbeginifclk'eventandclk='1'thencnt:=cnt+1;e

17、ndif;q<=cnt;endprocess;endsel_arc;模块CCC如图8-84所示。该模块的输入为ieee;useieee.std_logic_1164.all;entitycccisport(clk:instd_logic;q500,qlk:outstd_logic);endccc;architectureccc_arcofcccissignalx:std_logic;beginprocess(clk)variablecnt:integerrange0to499;beginifclk'eventandclk='1'thenifcnt<499th

18、encnt:=cnt+1;elsecnt:=0;x<=notx;endif;endif;qlk<=x;endprocess;process(x)variabley:std_logic;beginifx'eventandx='1'theny:=noty;endif;q500<=y;endprocess;endccc_arc;模块DISP如图9-85所示。它是七段译码器。libraryieee;useieee.std_logic_1164.all;entitydispisport(d:instd_logic_vector(3downto0);q:outstdogic_vector(6downto0);enddisp;architecturedisp_arcofdispisbeginprocess(d)begincasediswhen"0000"=>q<="0111111"when&quo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论