已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
VHDL数字钟设计报告一、系统功能概述:1.进行一个具有时、分、秒的十进制数计时功能,时、分、秒各用两个数码管分别显示(小时从0023,分、秒从0059);2.可以进行手动校时,校分,校时完毕之后从校正点开始从新计时;3.具有定时功能,可以预设闹钟,并在预定的时间发出闹铃声;4具有整点报时功能,即从59分50秒起,每隔2秒钟发出一次低音“嘟”的信号,连续5次,最后一次发出高音“嘀”的信号,此信号结束即达到整点。二、系统组成以及系统各部分的设计:1.系统结构描述:输入输出端口设置port(reset: in std_logic; -上升沿有效,用于改变工作状态 sign:in std_logic;-高电平有效,用来控制校时,定时功能; clk: in std_logic;-计时脉冲; clk2: in std_logic;-闹铃脉冲; hourmusic1: out std_logic; hourmusic2: out std_logic; music: out std_logic;-闹铃端口; q5: out std_logic_vector(3 downto 0);-小时高位出口; q4: out std_logic_vector(3 downto 0);-小时低位出口; q3: out std_logic_vector(3 downto 0);-分钟高位出口; q2: out std_logic_vector(3 downto 0);-分钟低位出口; q1: out std_logic_vector(3 downto 0);-秒钟高位出口; q0: out std_logic_vector(3 downto 0) -秒钟低位出口;);end clock;中间变量设置signal qq5,qq4,qq3,qq2,qq1,qq0: std_logic_vector(3 downto 0);用于计时,校时时时、分、秒的对应中间变量;signal qqhh,qqhl,qqmh,qqml: std_logic_vector(3 downto 0);用于定时时时、分、秒的对应中间变量;signal qqq5,qqq4,qqq3,qqq2,qqq1,qqq0: std_logic_vector(3 downto 0);用于显示时时、分、秒的对应中间变量;signal flag: std_logic_vector(2 downto 0);用来标记计时,定时,校时的状态;signal musica: std_logic;闹铃的中间变量;signal hourmusic11,hourmusic22: std_logic;整点报时的中间变量;signal k: std_logic;用来控制整点报时; 计时电路:process(reset)-通过reset上升沿触发调整工作状态;beginif (resetevent and reset=1) thenif flag=100 then-若flag等于4,则清零,否则加1;flag=000;elseflag=flag+1;end if;end if;end process;process(clk,flag,sign)-用于计时,校时,定时;beginif (clkevent and clk=1) thenk=not k; -产生二分频,用来控制后面整点报时;if flag=000 then -计时环节 if qq0=1001 thenqq0=0000;if qq1=0101 thenqq1=0000;if qq2=1001 thenqq2=0000;if qq3=0101 thenqq3=0000;if qq4=1001 thenqq4=0000;qq5=qq5+1;elsif qq5=0010and qq4=0011 thenqq4=0000; qq5=0000;elseqq4=qq4+1;end if;elseqq3=qq3+1;end if;elseqq2=qq2+1;end if;else qq1=qq1+1;end if;elseqq0=qq0+1;end if; 校时电路:elsif (flag=001 and sign=1)then -校时if qq4=1001 thenqq4=0000;qq5=qq5+1;elsif qq5=0010and qq4=0011 thenqq4=0000; qq5=0000;elseqq4=qq4+1;end if;elsif (flag=010 and sign=1) then -校分qq1=0000;qq0=0000;if qq2=1001 thenqq2=0000;if qq3=0101 thenqq3=0000;elseqq3=qq3+1;end if;else qq2=qq2+1;end if;定时电路:elsif (flag=011 and sign=1) then -定时if qqhl=1001 thenqqhl=0000;qqhh=qqhh+1;elsif qqhh=0010and qqhl=0011 thenqqhh=0000; qqhl=0000;elseqqhl=qqhl+1;end if;elsif (flag=100 and sign=1)then -定分if qqml=1001 thenqqml=0000;if qqmh=0101 thenqqmh=0000;elseqqmh=qqmh+1;end if;else qqml=qqml+1;end if;end if;end if;end process;显示:process(flag) beginif flag=000 then -计时状态,显示计时qqq0=qq0;qqq1=qq1;qqq2=qq2;qqq3=qq3;qqq4=qq4;qqq5=qq5;elsif flag=001 then-校时状态,显示校时qqq5=qq5;qqq4=qq4;qqq3=qq3;qqq2=qq2;qqq1=0000;qqq0=0001;elsif flag=010 then-校分状态,显示校分qqq5=qq5;qqq4=qq4;qqq3=qq3;qqq2=qq2;qqq1=0000;qqq0=0010;elsif flag=011 then-定时状态,显示定时 qqq5=qqhh;qqq4=qqhl;qqq3=qqmh;qqq2=qqml;qqq1=0000;qqq0=0011;elsif flag=100 then-定分状态,显示定分 qqq5=qqhh;qqq4=qqhl;qqq3=qqmh;qqq2=qqml;qqq1=0000;qqq0=0100;end if;end process;报时: process(flag)beginif flag=000 thenif qq5=qqhh and qq4=qqhl and qq3=qqmh and qq2=qqml thenif qq1=0000 thenmusica=clk2;end if;end if;end if;end process;process(k) -整点报时环节,当59分50秒时,每过两秒报时响一下,beginif (qq3=0101 and qq2=1001 and qq1=0101) and (qq0=1000 or qq0=1001) thenhourmusic22=k;elsif (qq3=0101and qq2=1001 and qq1=0101) thenhourmusic11=k;end if;(2)各进程功能总结:process(reset):手动上升沿触发,每来一次脉冲,状态变量flang加1,改变一种状态,当flang等于4时,flang清零,从新改变状态;process(clk,flag,sign):clk上升沿触发,当flang为“000”,完成正常计时;当flang为“001”且校正开关sign为高电平,完成校时功能;当flang为“010”且校正开关sign为高电平,完成校分功能;当flang为“011”且校正开关sign为高电平,完成定时功能;当flang为“100”且校正开关sign为高电平,完成定分功能;process(flag)1:完成显示功能:当flang为“000”时,显示正常计时的变量;当flang为“001”或“010”时(校时);显示校时校分变量;当flang为“011”或“100”时(定时),显示定时定分变量;process(flag)2:完成闹铃功能:当flang为“000”(正常计时状态)时,若计时和定时相等,则将clk2(引入的一个高频信号)给闹铃引脚(music,接speaker),闹铃响; process(k):k为clk进程中的一个二分频变量,完成整点报时功能:当计时为59分50秒时,hourmusic11赋值为k,即每隔两秒出现一次高电平,一共四次;当计时为59分58秒时,hourmusic22赋值为k,即每隔两秒出现一次高电平,一共一次;2. 下载时选择的开发系统模式以及管脚此系统下载时使用模式7进行下载:接口名称类型(输入/输出)结构图上的信号名引脚号clk输入Clk0153clk2 输入Clk529 reset 输入键1-PIO0233sign 输入键5-PIO4237music输出speaker174hourmusic1 输出D1-PIO40161hourmusic2 输出D2-PIO41162q0 输出PIO16-PIO1913/14/15/16q1输出PIO20-PIO2317/18/19/20q2 输出PIO24-PIO2721/41/128/132q3 输出PIO28-PIO31133/134/135/136q4 输出PIO32-PIO35137/138/139/140q5 输出PIO36-PIO39141/158/159/1603.实验电路结构图:结构图NO.7:此电路适合于设计时钟、定时器、秒表等。因为可利用键8和键5分别控制时钟的清零和设置时间的使能;利用键7、5和1进行时、分、秒的设置。 实验电路结构图如下:附录 :整体代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity clock isport(reset: in std_logic; sign:in std_logic; clk: in std_logic; clk2: in std_logic; hourmusic1: out std_logic; hourmusic2: out std_logic; music: out std_logic; q5: out std_logic_vector(3 downto 0); q4: out std_logic_vector(3 downto 0); q3: out std_logic_vector(3 downto 0); q2: out std_logic_vector(3 downto 0); q1: out std_logic_vector(3 downto 0); q0: out std_logic_vector(3 downto 0);end clock;architecture a of clock issignal qq5,qq4,qq3,qq2,qq1,qq0: std_logic_vector(3 downto 0);signal qqhh,qqhl,qqmh,qqml: std_logic_vector(3 downto 0);signal qqq5,qqq4,qqq3,qqq2,qqq1,qqq0: std_logic_vector(3 downto 0);signal flag: std_logic_vector(2 downto 0);signal musica: std_logic;signal hourmusic11,hourmusic22: std_logic;signal k: std_logic;beginprocess(reset)beginif (resetevent and reset=1) thenif flag=100 thenflag=000;elseflag=flag+1;end if;end if;end process;process(clk,flag,sign)beginif (clkevent and clk=1) thenk=not k;if flag=000 then if qq0=1001 thenqq0=0000;if qq1=0101 thenqq1=0000;if qq2=1001 thenqq2=0000;if qq3=0101 thenqq3=0000;if qq4=1001 thenqq4=0000;qq5=qq5+1;elsif qq5=0010and qq4=0011 thenqq4=0000; qq5=0000;elseqq4=qq4+1;end if;elseqq3=qq3+1;end if;elseqq2=qq2+1;end if;else qq1=qq1+1;end if;elseqq0=qq0+1;end if;elsif (flag=001 and sign=1)then if qq4=1001 thenqq4=0000;qq5=qq5+1;elsif qq5=0010and qq4=0011 thenqq4=0000; qq5=0000;elseqq4=qq4+1;end if;elsif (flag=010 and sign=1) then qq1=0000;qq0=0000;if qq2=1001 thenqq2=0000;if qq3=0101 thenqq3=0000;elseqq3=qq3+1;end if;else qq2=qq2+1;end if;elsif (flag=011 and sign=1) then if qqhl=1001 thenqqhl=0000;qqhh=qqhh+1;elsif qqhh=0010and qqhl=0011 thenqqhh=0000; qqhl=0000;elseqqhl=qqhl+1;end if;elsif (flag=100 and sign=1)then if qqml=1001 thenqqml=0000;if qqmh=0101 thenqqmh=0000;elseqqmh=qqmh+1;end if;else qqml=qqml+1;end if;end if;end if;end process;process(flag) beginif flag=000 then qqq0=qq0;qqq1=qq1;qqq2=qq2;qqq3=qq3;qqq4=qq4;qqq5=qq5;elsif flag=001 thenqqq5=qq5;qqq4=qq4;qqq3=qq3;qqq2=qq2;qqq1=0000;qqq
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 郑州采油气井口装置项目可行性研究报告
- 长丝生产技术改造融资投资立项项目可行性研究报告(2025咨询)2025
- 防火门可行性研究报告样本8
- 陶瓷加工项目可行性研究报告项目建议书
- 黄栀子深加工项目可行性研究报告完整立项报告
- 2025年山东档案职称考试《档案工作实务》考试题库(浓缩500题)
- 2020-2025年中级经济师之中级经济师经济基础知识题库与答案
- 2020-2025年初级经济师之初级经济师人力资源管理基础试题库和答案要点
- 代领三方协议书
- 屠宰厂待宰协议书
- 洁净室运行维护管理方案
- 2024-2030年中国少儿英语培训行业发展分析及发展前景与趋势预测研究报告
- 社区获得性肺炎诊疗规范
- TDT 1083-2023 国土调查数据库更新数据规范
- 《失智老年人照护》课件-项目四:失智老年人康复照护
- 中国法律史-第三次平时作业-国开-参考资料
- 2020-2021学年重庆市大渡口区九年级(上)期末数学试卷 (解析版)
- 西宁物业行业现状分析
- 彩票销售人员工作汇报
- 胆总管结石护理教学查房
- 电商云仓商业计划书
评论
0/150
提交评论