数字电子钟的VHDL程序设计实验报告.doc_第1页
数字电子钟的VHDL程序设计实验报告.doc_第2页
数字电子钟的VHDL程序设计实验报告.doc_第3页
数字电子钟的VHDL程序设计实验报告.doc_第4页
数字电子钟的VHDL程序设计实验报告.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

实验报告实验项目名称:数字电子钟的vhdl程序设计实验项目性质:普通试验所属课程名称:vhdl程序设计实验计划学时:4学时一、 实验目的 掌握vhdl程序设计方法二、 实验内容和要求能够实现小时(24进制)、分钟和秒钟(60进制)的计数功能具有复位功能功能扩展:具有复位、整点报时提示、定时闹钟等功能在软件工具平台上,进行vhdl语言的各模块编程输入、编译实现和仿真验证。三、 实验主要仪器设备和材料 计算机四、 实验方法、步骤及结果测试数字电子钟由计数器、比较器,寄存器和校时电路组成。振荡器产生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照“24翻1”规律计数。计数器的输出分别经译码器送显示器显示。1)时钟产生电路。将开发板上的时钟信号经过分频得到不同频率的时钟,分别作用于定时计数、led扫描。2)控制逻辑电路。完成电子钟的系统逻辑控制,包括计时控制、时间校对、显示扫描的逻辑控制,可完成系统复位、调整时间的功能。3)计时电路。主要按照时钟模式完成计时功能。4)闹钟电路。通过输入信号与电子钟比较,输出闹钟信号。各功能模块的设计60进制计数器设计秒数的计数以1hz的输入clks为触发信号,分数的计数以秒数的进位输出作为触发。是60进制计数器器件图形。接口: clks:1hz时钟信号 outs:输出显示 res:复位信号 inmin:输出十进制信号每来一个clks上升沿,计数器就加1,当计数器当到达第60个上升沿时,由59归零,仿真符合60进制计数器的要求。24进制计数器设计24进制计数器的结构和原理与60进制计数器相类似,只是将除以60改为除以24。下是生成的24进制计数器器件图形。接口: clkh:分的进位信号 res:复位信号 outh:输出十进制的小时数每来一个clkh上升沿,计数器就加1,当计数器当到达第24个上升沿时,outh由24归零,仿真符合24进制计数器的要求。整点报时及闹钟设计思路及原理图当计数时间在59分59秒时,报时模块输出报时控制信号。在报时设定时间与计数信号相同时,闹钟控制信号输出。接口: nzs1 nzm2 nzh1:时钟计数信号 nzs2 nzm2 nzh2:设定闹钟信号 q:报时响铃信号由图可知,当时钟计数信号和设定闹钟信号相同时,报时响铃信号q输出。当时钟计数信号为零(整点)时,报时响铃信号q输出。顶层设计通过调用各模块功能,得出如下仿真波形,证明设计成功,能够完成闹钟功能及整点报时功能。接口:clk,res:输入时钟脉冲,复位信号 leds,ledm,ledh:时钟显示信号 nzs,nzm,nzh:输入闹钟设置信号 qqq :响铃信号程序代码顶层程序文件library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clock isport(clk,res:in std_logic; leds,ledm,ledh:out std_logic_vector(5 downto 0); nzs,nzm,nzh:in std_logic_vector(5 downto 0); qqq :out std_logic); end clock;architecture behav of clock iscomponent sec port(clks: in std_logic; res1: in std_logic; inmin:out std_logic; outs:out std_logic_vector(5 downto 0);end component;component minport(clkm: in std_logic; res2: in std_logic; inhour:out std_logic; outm:out std_logic_vector(5 downto 0);end component;component hourport(clkh: in std_logic; res3: in std_logic; outh:out std_logic_vector(5 downto 0);end component;component nzport(nzs1,nzs2,nzm1,nzm2,nzh1,nzh2:in std_logic_vector(5 downto 0); q :out std_logic);end component; signal s: std_logic_vector(5 downto 0);signal m: std_logic_vector(5 downto 0);signal h: std_logic_vector(5 downto 0);signal a: std_logic;signal b: std_logic;signal c: std_logic;beginu1 :sec port map(clks=clk,res1=res,inmin=a,outs=s);u2 :min port map(clkm=a,res2=res,inhour=b,outm=m);u3 :hour port map(clkh=b,res3=res,outh=h);u4:nzportmap(nzs1=s,nzm1=m,nzh1=h,nzs2=nzs,nzm2=nzm,nzh2=nzh,q=c);leds=s;ledh=h;ledm=m;qqq=c;end architecture behav;秒钟计时模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sec isport(clks: in std_logic; res: in std_logic; inmin:out std_logic; outs:out std_logic_vector(5 downto 0);end sec;architecture behav of sec issignal s1:std_logic_vector(5 downto 0);signal s2:std_logic;beginprocess(clks,res)beginif res =1 then s1=000000;s2=0;elsif clksevent and clks=1 then if s1111011 then s1=s1+1;s2=0; elsif s1=111011 then s1=000000;s2=1; end if;end if;inmin=s2;outs=s1;end process;end behav;分钟计时模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity min isport(clkm: in std_logic; res: in std_logic; inhour:out std_logic; outm:out std_logic_vector(5 downto 0);end min;architecture behav of min issignal m1:std_logic_vector(5 downto 0):=111010;signal m2:std_logic;beginprocess(clkm,res)beginif res =1 then m1=000000;m2=0;elsif clkmevent and clkm=1 then if m1111011 then m1=m1+1;m2=0; elsif m1=111011 then m1=000000;m2=1; end if;end if;inhour=m2;outm=m1;end process;end behav;时钟计时模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport(clkh: in std_logic; res: in std_logic; outh:out std_logic_vector(5 downto 0);end hour;architecture behav of hour issignal h1:std_logic_vector(5 downto 0);beginprocess(clkh,res)beginif res =1 then h1=000000;elsif clkhevent and clkh=1 then if h1011000 then h1=h1+1; elsif h1=011000 then h1=000000; end if;end if;outh=h1;end process;end behav;闹钟及整点报时模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity nz isport(nzs1,nzs2,nzm1,nzm2,nzh1,nzh2:in std_logic_vector(5 downto 0); q :out std_logic);end nz;architecture behav of nz issignal qq:std_logic;beginprocess(nzs1,nzs2,nzm1,nzm2,nzh1,nzh2,qq)begin if (nzs1=nzs2 and nzm1=nzm2 and nzh1=nzh2)or (nzs1=000000and nzm1=000000) then qq=1; else qq=0; end if;q=qq;end process;end behav;总结本设计是用vhdl语言编写编译建模设计成的。由于初学vhdl语言,设计初期遇到了很多困难,在经过一段时间的查阅资料以及老师的指导和同学之间的相互讨论后完成了设计,但程序即使编译成功仿真还是遇到了很多困难,比如不知道该如何进行模块例化

温馨提示

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

评论

0/150

提交评论