EDA课程设计实验报告电子钟的设计

上传人:仙*** 文档编号:28739946 上传时间:2021-09-09 格式:DOC 页数:21 大小:3.49MB
返回 下载 相关 举报
EDA课程设计实验报告电子钟的设计_第1页
第1页 / 共21页
EDA课程设计实验报告电子钟的设计_第2页
第2页 / 共21页
EDA课程设计实验报告电子钟的设计_第3页
第3页 / 共21页
点击查看更多>>
资源描述
EDA课程设计实验报告系别:自动化工程系专业:电子测量技术与仪器同组人员: 指导老师: 一 电子钟的设计一设计要求:1.能实现时,分,秒计时。2.能实现整电报时。3.能进行对时和分的校准。二实验目的:1.掌握多位计数器相连的方法。2.掌握十六进制,二十四进制,六十进制计数器的设计方法。3.握CPLD技术的层次化设计法。4.了解软件的元件管理含义以及模块元件之间的连接概念。5.掌握电子电路一般的设计方法,并了解电子产品的研制开发过程,基本掌握电子电路安装和调试方法。6.培养独立分析问题,团结解决问题的能力。三硬件要求:1. 8位8段扫描共阴极数码显示管。2. 三个按键开关(清零,校时,校分)。四设计原理1.数字钟的计时周期为24小时,显示满刻度为23时59分59秒,另外具备校时功能和报时功能。因此,一个基本的数字钟主要由“时”“分”“秒”计数器校时电路组成。将标准信号送入“秒计数器”,“秒计数器”采用60进制计数器,每累加60 秒发送一个“分脉冲”信号,该信号将被送到“时计数器”,“时计数器”采用24进制计数器,可实现对一天24 小时的累计。译码显示电路将“时”“分”“秒”计数器的输出状态六段显示译码器译码。通过六位LED七段显示器显示出来2.校时电路是用来对“时”“分”显示数字进行校时调整的。五电子时钟模块设计1. 分频模块FENPIN设计模块FENPIN原理图如下:图3 FENPIN原理图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 thenb=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;daout: 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;enmin1=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 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=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原理图如下,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 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的源程序library 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_vector(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 downto 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;end 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 顶层文件原理图时序仿真:程序仿真主要由计数器完成,在时钟脉冲作用下,完成始终功能,由时序图可以看出每个时钟上升沿到来时加一,当接受到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;实验总结:通过本次实验我们了解到电子时钟的设计原理,让我们更加了解到这些生活中的东西怎么设计出来的,并且学会找出错误,改正错误。对时、分、秒的设计了解到很多知道,通过本次学习对我们以后有了很大的帮助。二 交通灯设计设计说明:现代,在城市的交通繁忙的交叉路口,行人比较多的路口,或学校附近都设有许多的红绿交通灯。它指示着行人、车辆有序的通行。其中,红灯停,绿灯行,黄灯表警示。在灯的旁边还有数字晶体显示器,用于提示行人、司机三种颜色的灯即将跳转所剩的时间,让其做好应有的准备。一 设计要求:1 在十字路口的方向上各设一组红绿黄灯,显示顺序为:其中一个方向是绿灯、黄灯、红灯,另外一个方向是红灯、绿灯、黄灯。2 设置4个数码管,以倒计时的方式显示允许通过或禁止的时间,其中绿灯、黄灯、红灯的持续时间分别是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);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=clk2;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,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 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;shi1=shi;ge1d:=ge;when 000=d:=shi;when others=d:=0000;end case;yc(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;end case;if(sel=001 or sel=011 or sel=101) then c(7)=1;else c(7)=0;end if;y=c;end process;end rt1;图1-11 波形仿真图四、顶层原理图图1-2 顶层原理图波形仿真图如下:图1-3交通灯仿真波形引脚锁定Clk=83,clr=31,sel0=70,sel1=69,sel2=68,y0=81,y1=80,y2=79,y3=77,y4=76,y5=75,Y6=74,y7=73;实验总结:1. 自己针对顶层文件的修改:a.如果将下图CLK接到CLR上则将出现选择出错。即:输入的信号的频率和选择器的频率一致,因此它将始终停在一个状态。b.如果将下图的SEL对GE,SHI的选择交换,则会出现计时反向;如果将个、十交换位置。则将造成计时器的时间出错。2.体会通过本次设计,让我更加对日常生活中的事物产生了兴趣,了解到现实中的一件事都是有规律的。只要认真对其分析,就能找到相应的结果。
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 办公文档


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!