EDA课程设计实验报告电子钟的设计_第1页
EDA课程设计实验报告电子钟的设计_第2页
EDA课程设计实验报告电子钟的设计_第3页
EDA课程设计实验报告电子钟的设计_第4页
EDA课程设计实验报告电子钟的设计_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、eda课程设计实验报告系别:自动化工程系专业:电子测量技术与仪器同组人员: 指导老师: 一 电子钟的设计一设计要求:1.能实现时,分,秒计时。2.能实现整电报时。3.能进行对时和分的校准。二实验目的:1.掌握多位计数器相连的方法。2.掌握十六进制,二十四进制,六十进制计数器的设计方法。3.握cpld技术的层次化设计法。4.了解软件的元件管理含义以及模块元件之间的连接概念。5.掌握电子电路一般的设计方法,并了解电子产品的研制开发过程,基本掌握电子电路安装和调试方法。6.培养独立分析问题,团结解决问题的能力。三硬件要求:1. 8位8段扫描共阴极数码显示管。2. 三个按键开关(清零,校时,校分)。四

2、设计原理1.数字钟的计时周期为24小时,显示满刻度为23时59分59秒,另外具备校时功能和报时功能。因此,一个基本的数字钟主要由“时”“分”“秒”计数器校时电路组成。将标准信号送入“秒计数器”,“秒计数器”采用60进制计数器,每累加60 秒发送一个“分脉冲”信号,该信号将被送到“时计数器”,“时计数器”采用24进制计数器,可实现对一天24 小时的累计。译码显示电路将“时”“分”“秒”计数器的输出状态六段显示译码器译码。通过六位led七段显示器显示出来2.校时电路是用来对“时”“分”显示数字进行校时调整的。五电子时钟模块设计1. 分频模块fenpin设计模块fenpin原理图如下:图3 fenp

3、in原理图fenpin源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenp isport(clk1:in std_logic;clk:out std_logic);end;architecture one of fenp issignal a:std_logic_vector(8 downto 0);signal b,c:std_logic;beginprocess(clk1)beginif clk1event and clk1=1 thenif a=100000000 t

4、henb=1;a=000000000;elsea=a+1;b=0;end if;end if;end process;clk=b;end;仿真波形如下:图4 fenpin 波形图2. 模块miao1设计模块miao1原理图如下,clk和reset控制daout,setime和clk控制enmin图5 second的原理图miao1 的源程序如下library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity miao1 isport (clk,reset,setmin: in std_logic;da

5、out: out std_logic_vector(6 downto 0);enmin:buffer std_logic);end;architecture two of miao1 issignal d:std_logic_vector(6 downto 0);signal enmin1,enmin2:std_logic;beginprocess(clk,reset,setmin)beginif reset=1then d=0000000;elsif (clkevent and clk=1) thenif d16#60# thenif d=1011001 thend=0000000;enmi

6、n1=1;else d=d+1;enmin1=0;if d(3 downto 0)=1001 then d=d+7;end if;end if;end if; end if; end process;daout=d;enmin=(enmin1 or enmin2);enmin2=(setmin and clk);end;波形仿真图如下图1-4 miao1 的波形仿真3. 模块fenz设计模块fenz原理图如下,clk和reset控制daout,sehour控制enhour图6 fen图fenz的源程序如下library ieee;use ieee.std_logic_1164.all;use

7、ieee.std_logic_unsigned.all;entity fen isport (reset,clk,sethour,clk1: in std_logic;daout: out std_logic_vector(6 downto 0);enhour:buffer std_logic);end;architecture two of fen issignal d:std_logic_vector(6 downto 0);signal enhour1,enhour2:std_logic;beginprocess(clk,clk1,reset,sethour)beginif reset=

8、1then d=0000000;elsif (clkevent and clk=1) thenif d16#60# thenif d=1011001 thend=0000000;enhour1=1;else d=d+1;enhour1=0;if d(3 downto 0)=1001 then d=d+7;end if;end if;end if; end if; end process;daout=d;enhour=(enhour1 or enhour2);enhour2=(sethour and clk1);end;波形仿真图如下图7 fenz 的波形仿真4. 模块hour设计模块hour原

9、理图如下,clk和reset控制daout。图8 hour的原理图hour的源程序如下library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport (reset,clk: in std_logic;daout: out std_logic_vector (5 downto 0);end;architecture two of hour issignal d:std_logic_vector(5 downto 0);beginprocess(clk,reset)beginif

10、 reset=1then d=000000;elsif (clkevent and clk=1) thenif d16#60# thenif d=100011 thend=000000;else d=d+1; if d(3 downto 0)=1001 then d=d+7;end if;end if;end if; end if; end process;daout=d;end;波形仿真图如下 图9 hour 的波形仿真5. 模块xians设计模块xians原理图如下,当sel取不同值时daout分别选择输出sec .min .hour图10 seltime的原理图seltime的源程序li

11、brary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity seltime isport(clk2,reset:in std_logic; hour,sec,min:in std_logic_vector(6 downto 0); daout :out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0);end; architecture bhv of seltime is signal q1:std_logic_ve

12、ctor(2 downto 0);beginprocess(clk2,reset) variable daa:std_logic_vector(3 downto 0); begin if reset=1then daout=0000;sel=000; elsif clk2event and clk2=1then q1daa:=sec(3 downto 0);when 100=daa:=0&sec(6 downto 4);when 011=daa:=min(3 downto 0);when 010=daa:=0&min(6 downto 4);when 001=daa:=hour(3 downt

13、o 0);when 000=daa:=0&hour(6 downto 4);when others=daa:=0000;end case;sel=q1;daoutc(6 downto 0)c(6 downto 0)c(6 downto 0)c(7 downto 0)c(6 downto 0)c(6 downto 0)c(6 downto 0)c(7 downto 0)c(6 downto 0)c(6 downto 0)c(6 downto 0)c(7 downto 0)c(6 downto 0)c(6 downto 0)c(6 downto 0)c(6 downto 0)=0000000;en

14、d case;if(sel=001 or sel=011 or sel=101) then c(7)=1;else c(7)=0;end if;ylam:=000;when01=lam:=001;when10=lam:=010;when11=lam:=100;when others=lam:=000;end case;end if;if h=1thenlamp=lam;else lamp=000;end if;speak=h;end process;end;仿真波形如下:图15 baos波形图顶层原理图如下:图1 顶层文件原理图时序仿真:程序仿真主要由计数器完成,在时钟脉冲作用下,完成始终功能

15、,由时序图可以看出每个时钟上升沿到来时加一,当接受到rest信号,即rest为高电平,所有计数为零,并重新计数,setmin 和sethour可以完成调节时钟功能,都是高电平调节,每来一个脉冲,相应的时或分加1。图2 时序仿真引脚锁定clk=83,lamp0=51,lamp1=50,lamp2=49,led7s0=81,led7s1=80,led7s2=79,led7s3=77,led7s4=76,led7s5=75,led7s6=74,led7s7=73;res=45,sel0=70,sel1=69,sel2=68;sethour=41,setmin=44;实验总结:通过本次实验我们了解到电

16、子时钟的设计原理,让我们更加了解到这些生活中的东西怎么设计出来的,并且学会找出错误,改正错误。对时、分、秒的设计了解到很多知道,通过本次学习对我们以后有了很大的帮助。二 交通灯设计设计说明:现代,在城市的交通繁忙的交叉路口,行人比较多的路口,或学校附近都设有许多的红绿交通灯。它指示着行人、车辆有序的通行。其中,红灯停,绿灯行,黄灯表警示。在灯的旁边还有数字晶体显示器,用于提示行人、司机三种颜色的灯即将跳转所剩的时间,让其做好应有的准备。一 设计要求:1 在十字路口的方向上各设一组红绿黄灯,显示顺序为:其中一个方向是绿灯、黄灯、红灯,另外一个方向是红灯、绿灯、黄灯。2 设置4个数码管,以倒计时的

17、方式显示允许通过或禁止的时间,其中绿灯、黄灯、红灯的持续时间分别是30秒、5秒、35秒。二 设计原理图状态转换图三、各模块设计1、模块cnt8设计模块fenpin如下图,该模块的功能是将时间256分频,得到占空比为1:256的方波。图1-4 cnt8顶层图分频器fp程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fp isport( clk :in std_logic; sel:out std_logic_vector(2 downto 0) ;d :out std_logic

18、);end; architecture bhv of fp is signal clk2:std_logic;signal q :std_logic_vector(2 downto 0) ;beginprocess(clk,clk2)variable count:std_logic_vector(7 downto 0);begin if clkevent and clk=1then if count=10000000 then clk2=not (clk2);count:=00000000; else count:=count+1; end if; end if;end process;d=c

19、lk2;process(clk)beginif clkevent and clk=1then q=q+1;end if;end process;sel=q;end bhv; 波形仿真如下:图1-5 cnt8波形仿真图2、模块jtd设计如图1-2,该模块为整个程序的核心,它实现东西和南北方向的三种交通灯颜色的交替点亮、时间的倒计时。图1-6 jtd顶层图jtd的源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity deng isport(clk,clr:in std_logic; dx

20、,nb:out std_logic_vector(2 downto 0); shi1,ge1:out std_logic_vector(3 downto 0) );end; architecture ad of deng issignal shi,ge:std_logic_vector(3 downto 0); type fsm_st is (s1,s0,s2,s3); signal state :fsm_st; begin process(clk,clr) beginif clr=1then state=s0;ge=0000;shidx=100;nb=001;if ge=0000 then

21、if shi=0000 then state=s1; ge=0101;shi=0000; else shi=shi-1; ge=1001; end if; else gedx=100;nb=010; if ge=0000 then if shi=0000 then state=s2;ge=0000;shi=0011;else shi=shi-1;ge=0000;end if;else gedx=001;nb=100; if ge=0000 then if shi=0000 then state=s3;ge=0101;shi=0000;else shi=shi-1;ge=1001;end if;else gedx=010;nb=100; if ge=0000 then if shi=0000 then state=s0;ge=0000;shi=0011;else shi=shi-1;ge=0101;end if;else ge=ge-1;end if;end case;end if;s

温馨提示

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

评论

0/150

提交评论