数字逻辑电路课程设计-多功能数字钟.doc_第1页
数字逻辑电路课程设计-多功能数字钟.doc_第2页
数字逻辑电路课程设计-多功能数字钟.doc_第3页
数字逻辑电路课程设计-多功能数字钟.doc_第4页
数字逻辑电路课程设计-多功能数字钟.doc_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

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

文档简介

J计算机1401 谢舟 4141110023江苏大学数字逻辑电路课程设计课题:多功能数字钟学号:姓名: 专业班级:J 计算机1401学院:京 江 学 院 指导老师: 2016年1月9日目录一、 实验目的 .1二、 顶层图 .1三、 系统功能分析 .11.时、分、秒的基本组成VHDL .12.分配器和二路选择器 .43.计时和校时模块.54.整点报时模块 .65.分频模块 .76.动态显示模块 .87.闹钟模块 .11四、 引脚锁定.12五、 心得体会.122一、 实验目的 多功能数字钟具有以下功能:(1) 能进行正常的时、分、秒计时。(2) 可使用以EP1C12F324C8为核心的硬件系统上的脉冲按键或者拨动开关实现“校时”、“校分”及秒清零功能。(3) 可使用以EP1C12F324C8为核心的硬件系统上的扬声器进行整点报时。(4) 设置闹钟,并连接扬声器实现闹铃功能。(5) 通过以EP1C12F324C8为核心的硬件系统上的动态扫描数码管显示时间。二、顶层图三、 系统功能分析根据总体设计框图,可以将整个系统分为6个模块来实现,分别是计时模块、校时模块、整点报时模块、分频模块、动态显示模块及闹钟模块。1.时、分、秒的基本组成VHDL(1)24进制计数器源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity cnt24 isport(clk:in std_logic; ql,qh:out std_logic_vector(3 downto 0); tc:out std_logic);end cnt24;architecture one of cnt24 is signal l,h:std_logic_vector(3 downto 0);signal co:std_logic; begin process(clk) begin if (clkevent and clk=1) then if (l1001 and (h=0000 or h=0001) then l=l+1;h=h;co=0; end if; if(l=1001 and (h=0000 or h=0001) thenh=h+1;l=0000;co=0; end if; if(l0100 and h0010) thenl=l+1;h=h;co=0; end if; if(l=0011 and h=0010) then h=0000;l=0000;co=1; end if; end if; qh=h; ql=l; tc=co; end process; end one;模块图:(2)60进制计数器源程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt60 is port ( clk,clr:in std_logic; ql,qh:buffer std_logic_vector(3 downto 0); tc:out std_logic ); end cnt60;architecture behavor of cnt60 issignal h,l:std_logic_vector(3 downto 0);signal co:std_logic; begin process(clk,clr) begin if (clr=0) then h=0000; l=0000; co=0; elsif (clkevent and clk=1) then if (l=1001) then if (h=0101) then h=0000;l=0000;co=1; else h=h+1;l=0000;co=0; end if; else l=l+1;h=h; co=0; end if; end if; qh=h; ql=l; tc=co; end process; end behavor;模块图:2.分配器和二路选择器(1)分配器源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity dex2 isport(sel:in std_logic; data: in std_logic; o1,o2:out std_logic);end dex2;architecture beh of dex2 isbegin process(sel) beginif(sel=0)then o1=data;else o2=data; end if; end process;end beh;模块图:(2)二路选择器源程序:library ieee;use ieee.std_logic_1164.all;entity mux2 isport( A,B:in std_logic; S:in std_logic; Y:out std_logic );end mux2;architecture one of mux2 isbeginprocess(A,B,S)beginif (S=0) then Y=A;elseY=B;end if;end process;end one;模块图:3.计时和校时模块校时模块设计实现校时、校分及秒清零功能:1)按下校时键,小时计数器迅速递增以调至所需小时位。2)按下校分键,分计数器迅速递增以调至所需分位。3)按下清零键,将秒计数器清零。4.整点报时模块当计时至5950、5952、5954、5956、5958时,驱动扬声器低音报时,计时至整点时产生高音报时。输入端mh3.0和ml3.0用于连接分位,sh3.0和sl3.0用于连接秒位;输出端sig500用于产生低音报时,sig1k用于产生高音报时。源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity zdbs isport(mh,ml,sh,sl:in std_logic_vector(3 downto 0); sig500,sig1k: out std_logic);end zdbs;architecture behavior of zdbs isbegin sig500=1 when mh=0101and ml=1001and sh=0101and( sl=0000or sl=0010 or sl=0100or sl=0110or sl=1000) else 0;sig1k=1 when mh=0000and ml=0000and sh=0000and sl=0000 else 0;end behavior;模块图:5.分频模块在本系统中需要用到多种不同频率的脉冲信号,上至1kHz的高音报时信号,下至1Hz的计秒脉冲。所有这些脉冲信号均可以通过一个基准频率分频器生成。基准频率分频器就是一个进制很大的计数器,利用计数器的分频功能,从不同的输出为得到所需要的脉冲信号。输出HZ1、HZ4、HZ64和HZ512可分别得到1Hz、4Hz、64Hz和512Hz的脉冲信号。将clk时钟端外接硬件系统基准时钟可直接得到频率为1kHz的时钟信号。源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity freq_divider is port(clk:in std_logic;hz1,hz4,hz64,hz512:out std_logic);end freq_divider;architecture behavior of freq_divider is signal q:std_logic_vector(9 downto 0); beginprocess(clk)beginif(rising_edge(clk) thenq=q+1;end if;end process;hz1=q(9);hz4=q(7);hz64=q(3);hz512=q(0);end behavior;模块图:6.动态显示模块时间的显示需要用到6个数码管,静态显示不够用,在动态方式下,所有数码管对应同一组七段码,每一个数码管由一个选择控制端点亮或熄灭。这里用6进制计数器来进行选择控制,每组时间经过七段码译码后输出到6个数码管,当某一组时的七段码到达时,只点亮对应位置上的数码管,显示相应的数字,6次一循环,形成一个扫描序列,只要扫描频率超过人眼视觉暂留频率(24Hz),就可以达到点亮单个数码管,却能享有6个同时显示的视觉效果,人眼辨别不出差别。这里采用4-7译码器。控制信号sel用3-8译码器来控制。(1) 动态扫描显示模块源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity dtsm is port( clk:in std_logic; h:in std_logic_vector(7 downto 0); m:in std_logic_vector(7 downto 0); s:in std_logic_vector(7 downto 0); seg7out:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0) );end dtsm;architecture behave of dtsm is signal out1:std_logic_vector(3 downto 0); signal sel1:std_logic_vector(2 downto 0); begin p1:process(clk) begin if (rising_edge(clk) then sel1=sel1+1; end if; selout1out1out1out1out1out1out1out1seg7outseg7outseg7outseg7outseg7outseg7outseg7outseg7outseg7outseg7outseg7out=0000000; end case; end process p3; end behave;模块图:(2)显示选择模块源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity sel_show isport(jh,jm,nh,nm:in std_logic_vector(7 downto 0);sel:in std_logic;oh,om:out std_logic_vector(7 downto 0);end sel_show;architecture one of sel_show isbeginprocess(sel,jh,jm,nh,nm)beginif (sel=0) then oh=jh;om=jm;elseoh=nh;om=nm;end if;end process;end one;模块图:7.闹钟模块 比较正常计数时间与闹钟定时时间是否相等,若相等,ring_out输出”1”,反之输出”0”.源程序:library ieee;use ieee.std_logic_1164.all;entity compare isport( jh:in std_logic_vector(7 downto 0); jm:in std_logic_vector(7 downto 0); nh:in std_logic_vector(7 downto 0); nm:in std_logic_vector(7 downto 0); ring_out:out std_logic );end compare;architecture one of compare isbeginprocess(jh,jm,nh,nm) begin if(jh=nh and jm=nm) then ring_out=1; elsering_out=0; end if;end process;end one;模块图:四、 引脚锁定五、 心得体会经过此次数字钟的设计,我确实从中学到很多的东西。首先,通过VHDL硬件语言的学习,我充分认识到了功能模块如何用语言实现,让

温馨提示

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

评论

0/150

提交评论