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

下载本文档

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

文档简介

1、-. z数字电路课程设计VHDL语言数字钟一、系统功能概述完成秒分时的依次显示并正确计数;秒 / 分时各段个位满10正确进位,秒分能做到满60向前进位;定时闹钟:实现整点报时,又扬声器发出报时声音;时间设置即手动调时功能,能对不准确的时间进展分 / 时的调整。二、系统组成以及系统各局部的设计1、顶层文件2、系统以及各个模块的仿真波形分频模块原理图输入秒模块程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity SECOND isport(clk,clr:in std_logic;-时钟/

2、清零信号 sec1,sec0:out std_logic_vector(3 downto 0);-秒高位/低位 co:out std_logic);-输出/进位信号end SECOND;architecture SEC of SECOND isbeginprocess(clk,clr)variablet1,t0:std_logic_vector(3 downto 0);-计数beginif clr=1 then-当ckr为1时,上下位均为0t1:=0000;t0:=0000;elsif clkevent and clk=1 thenift1=0101 andt0=1000 then-当记数为5

3、8实际是经过59个记时脉冲co=1;-进位t0:=1001;-低位为9elsift01001 then-小于9时t0:=t0+1;-计数elset0:=0000;ift10101 then-高位小于5时t1:=t1+1;elset1:=0000;co=0;end if;end if;end if;sec1=t1;sec0=t0;end process;end SEC;3分模块程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity MINUTE isport(clk,en:in std_l

4、ogic; min1,min0:out std_logic_vector(3 downto 0); co:out std_logic);end MINUTE;architecture MIN of MINUTE isbeginif clkevent and clk=1 thenif en=1 thenift1=0101 andt0=1000 thenco=1;t0:=1001;elsift01001 thent0:=t0+1;elset0:=0000;nd MINUTE;architecture MIN of MINUTE isbeginift10101 thent1:=t1+1;elset1

5、:=0000;co=0;end if;end if;end if;end if;min1=t1;min0=t0;end process;end MIN;4时模块程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity HOUR isport(clk,en:in std_logic;-输入时钟/高电平有效的使能信号 h1,h0:out std_logic_vector(3 downto 0);-时高位/低位end HOUR;architecture hour_arc of HOUR isbe

6、ginprocess(clk)variablet1,t0:std_logic_vector(3 downto 0);-记数beginif clkevent and clk=1 then-上升沿触发if en=1 then-同时使能为1ift1=0010 andt0=0011 thent1:=0000;-高位/低位同时为0时t0:=0000;elsift01001 then-低位小于9时,低位记数累加t0:=t0+1;elset0:=0000;t1:=t1+1;-高位记数累加end if;end if;end if;h1=t1;h0=t0;end process;end hour_arc;5动态

7、扫描模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity SELTIME is port( clk:in std_logic;-扫描时钟 secm1,secm0,sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0);-分别为秒个位/时位;分个位/ daout:out std_logic_vector(3 downto 0);-输出 sel:out std_logic_

8、vector(2 downto 0);-位选信号end SELTIME;architecture fun of SELTIME is signal count:std_logic_vector(2 downto 0);-计数信号begin sel=111) then count=000; else countdaoutdaoutdaoutdaoutdaoutdaoutdaoutdaout=h1; end case; end process;end fun;6报时模块library ieee;use ieee.std_logic_1164.all;entity ALERT isport(m1,m

9、0,s1,s0:in std_logic_vector(3 downto 0);-输入秒、分高/低位信号 clk:in std_logic;-高频声控制 q500,qlk:out std_logic);-低频声控制end ALERT;architecture sss_arc of ALERT is begin process(clk) begin if clkevent and clk=1 then if m1=0101 and m0=1001 and s1=0101 then-当秒高位为5,低位为9时且分高位为5 if s0=0001 or s0=0011 or s0=0101 or s0=

10、0111 then-当分的低位为1或3或5或7时 q500=1;-低频输出为1 else q500=0;-否则输出为0 end if; end if;if m1=0101 and m0=1001 and s1=0101 and s0=1001 then-当秒高位为5,低位为9时且分高位为5,-分低位为9时,也就是59分59秒的时候报时 qlk=1;-高频输出为1 else qlk=0; end if;end if; end process; end sss_arc;7) 定时闹钟模块library ieee;use ieee.std_logic_1164.all;entity ALERT is

11、port(m1,m0,s1,s0:in std_logic_vector(3 downto 0); clk:in std_logic; q500,qlk:out std_logic);end ALERT;architecture sss_arc of ALERT is begin process(clk) begin if clkevent and clk=1 then if m1=0101 and m0=1001 and s1=0101 then if s0=0001 or s0=0011 or s0=0101 or s0=0111 then q500=1; else q500=0; end

12、 if; end if;if m1=0101 and m0=1001 and s1=0101 and s0=1001 thenqlk=1;elseqlk=0;end if;end if;end process;end sss_arc;-. z3、下载时选择的开发系统模式以及管脚定义表1 GW48-CK开发系统工作模式:接口名称类型(输入/输出)构造图上的信号名引脚号说明ClrIPIO716复位键ClkICLOCK02时钟EnIPIO49使能tOSpeaker3扬声器Sec0OPIO1627秒低位输出Sec1OPIO1728秒高位输出Min0OPIO2439分低位输出Min1OPIO2547分高位输出H0OPIO3254时低位输出H1OPIO3358时高位输出三、课程设计过程中遇到的问题以及解决方法 由于第一次接触硬件描述语言,在开头感觉很有难度,但

温馨提示

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

评论

0/150

提交评论