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

下载本文档

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

文档简介

数电课程设计报告姓名: 段续班级: 计112-2学号:201158502222指导教师:王玲玲 数电课程设计报告多功能电子钟目录一、设计要求二、设计方案1设计需求1多功能电子钟的设计方案1电子钟模式1显示模式1选位模式2三、各功能模块设计3主控模块3主要功能3源代码3计时模块5主要功能5源代码5闹钟模块8主要功能8源代码8辅控模块10主要功能11源代码11显示模块14主要功能14源代码15蜂鸣器模块17主要功能17源代码17分频器模块18主要功能18源代码18四、设计实现过程20五、实验结果。讨论及心得体会22附录23各模块仿真图23AC23BCD7DIS23CHOSE2123CHOSE8123CLKCUT24COUNT2424COUNT6024KEYEN24MC24SOUND25SWSC25TRANSLATE382525一、设计要求1、具有以二十四小时制计时、显示、整点报时、时间设置和闹钟的功能。2、射击精度要求为1s。二、设计方案设计需求1.计时:正常工作状态下每天按24小时制计时并显示,蜂鸣器无声,逢整点报时。2.较时:在调时显示状态下,按下“k键”则进入“小时”校准状态,此时按“k键”则进入“分钟”校准状态,继续按“k键”则进入“秒钟”校准状态,再按k键”则反回全部闪烁状态。在较时状态时,被较准的,数码管以闪烁显示,此时若set键值为1则按照4HZ进行加时。3.整点报时:蜂鸣器在59分钟的51、53、55、57秒时发出频率为512hz的低音,在59秒时发出1024hz的高音,结束时为整点。4.显示:要求采用扫描显示方式驱动8个LED数码管显示“时-分-秒”。5.闹钟:闹钟定时时间到,蜂鸣器发出周期1秒的“滴、滴”声,持续时间为一分钟。6.闹钟设置:在闹钟调时时状态下,按下“k键”则进入“小时”定时状态,此时按“k键”则进入“分钟”定时状态,继续按“k键”则进入“秒钟”定时状态,再按k键”则回到全部闪烁状态。在定时状态时,被定时的,数码管以闪烁显示,此时若set键值为1则按照4HZ进行加时。为了实现这些功能需要一些小的模块来实现不同的功能,小模块的功能将在下面进行介绍。多功能电子钟的设计方案辅助控制模块主控模块显示模块计时模块 闹闹钟模块蜂鸣器模块电子钟模式显示模式选位模式开启电子钟正常显示秒钟闪烁分钟闪烁小时闪烁全部闪烁计时调时闹钟显示分钟闪烁小时闪烁全部闪烁闹钟调时秒钟闪烁 系统开启后,数码管正常显示。Functioswitch键按下,开始进入计时调时状态,在这个状态中,首先全部闪烁显示,K键按下,小时闪烁,K键按下,分钟闪烁,K键按下,秒钟闪烁。Functioswitch键按下,进入闹钟显示状态。Functioswitch键按下,进入闹钟调时状态,在这个状态中,首先全部闪烁显示,K键按下,小时闪烁,K键按下,分钟闪烁,K键按下,秒钟闪烁。三、各功能模块设计电子钟包括:主控模块,计时模块,闹钟模块,辅控模块,显示模块,蜂鸣器模块,分频器模块。主控模块主要功能控制整个系统,输出现在的状态,以及按键信息。源代码mc.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity mc isport(functionswitch,k,set,lightkey: in std_logic;chose21,setout: out std_logic;lightswitch:buffer std_logic;modeout,kmodeout : out std_logic_vector(1 downto 0);setcs,setcm,setch,setas,setam,setah:out std_logic);end mc;architecture work of mc issignal mode,kmode:std_logic_vector(1 downto 0);signal light,chose21buf:std_logic;signal setcount:std_logic_vector(5 downto 0);beginprocess(functionswitch,k,set,lightkey)beginif functionswitchevent and functionswitch=1 thenmode=mode+1;end if;if lightkeyevent and lightkey=1 thenlightswitch=not lightswitch;end if;if mode=01 thenchose21buf=0;else chose21buf=1;end if;if kevent and k=1 thenif mode=01 or mode=11 thenkmode=kmode+1;end if;end if;if set=1 thenif mode = 01 thenif kmode=01 then setcount=000001;elsif kmode=10 thensetcount=000010;elsif kmode=11 thensetcount=000100;elsesetcount=000000;end if;elsif mode = 11 then if kmode=01 then setcount=001000;elsif kmode=10 thensetcount=010000;elsif kmode=11 then setcount=100000;elsesetcount=000000;end if;end if;end if;if set=0 then setcount=000000;end if;setout=set;modeout=mode;kmodeout=kmode;chose21=chose21buf;setcs=setcount(0);setcm=setcount(1);setch=setcount(2);setas=setcount(3);setam=setcount(4);setah=setcount(5);end process;end work;计时模块主要功能记录时间,正常计时。源代码Count60.vhdlibrary ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity count60 isport( clk ,clr :in std_logic;co : out std_logic; outh :out std_logic_vector(7 downto 4);outl :out std_logic_vector(3 downto 0); end count60 ;architecture work of count60 issignal bufh:std_logic_vector(7 downto 4);signal bufl:std_logic_vector(3 downto 0);begin process(clk) beginif clr=0 thenbufh=0000;bufl=0000;elsif(clkevent and clk=1)thenif(bufh=0101and bufl=1001)thenco=1;bufh=0000;bufl=0000;elsif(bufl=1001)thenbufl=0000;bufh=bufh+1;elsebufl=bufl+1;co=0;end if;end if;outh=bufh;outl=bufl;end process;end work;count24.vhdlibrary ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity count24 is port( clk :in std_logic; co: out std_logic; outh :out std_logic_vector(7 downto 4); outl :out std_logic_vector(3 downto 0); end count24 ;architecture a of count24 issignal bufh:std_logic_vector(7 downto 4);signal bufl:std_logic_vector(3 downto 0);begin process(clk) beginif(clkevent and clk=1)thenif(bufh=0010and bufl=0011)thenco=1;bufh=0000;bufl=0000;elsif(bufl=1001)thenbufl=0000;bufh=bufh+1;elsebufl=bufl+1;co=0;end if;end if;outh=bufh;outl=bufl;end process;end a;keyen.vhdlibrary ieee;use ieee.std_logic_1164.all;entity keyen isport(en, keyin:in std_logic;keyout: out std_logic);end keyen;architecture work of keyen isbeginprocess(en,keyin)beginif en=1 then keyout=keyin;else keyout=0;end if;end process;end work;chose21.vhdlibrary ieee;use ieee.std_logic_1164.all;entity chose21 isport(clk,add,chose : in std_logic;co : out std_logic);end chose21;architecture work of chose21 isbeginprocess(chose,clk,add)beginif chose=1 then co=clk;elseco=add;end if;end process;end work;闹钟模块主要功能记录闹钟时间信息,输出闹钟时间信息源代码Keyen.vhdlibrary ieee;use ieee.std_logic_1164.all;entity keyen isport(en, keyin:in std_logic;keyout: out std_logic);end keyen;architecture work of keyen isbeginprocess(en,keyin)beginif en=1 then keyout=keyin;else keyout=0;end if;end process;end work;count60.vhdlibrary ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity count60 isport( clk ,clr :in std_logic;co : out std_logic; outh :out std_logic_vector(7 downto 4);outl :out std_logic_vector(3 downto 0); end count60 ;architecture work of count60 issignal bufh:std_logic_vector(7 downto 4);signal bufl:std_logic_vector(3 downto 0);begin process(clk) beginif clr=0 thenbufh=0000;bufl=0000;elsif(clkevent and clk=1)thenif(bufh=0101and bufl=1001)thenco=1;bufh=0000;bufl=0000;elsif(bufl=1001)thenbufl=0000;bufh=bufh+1;elsebufl=bufl+1;co=0;end if;end if;outh=bufh;outl=bufl;end process;end work;count24.vhdlibrary ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity count24 is port( clk :in std_logic; co: out std_logic; outh :out std_logic_vector(7 downto 4); outl :out std_logic_vector(3 downto 0); end count24 ;architecture a of count24 issignal bufh:std_logic_vector(7 downto 4);signal bufl:std_logic_vector(3 downto 0);begin process(clk) beginif(clkevent and clk=1)thenif(bufh=0010and bufl=0011)thenco=1;bufh=0000;bufl=0000;elsif(bufl=1001)thenbufl=0000;bufh=bufh+1;elsebufl=bufl+1;co=0;end if;end if;outh=bufh;outl=bufl;end process;end a;辅控模块主要功能处理显示,以及蜂鸣器的信号。时钟输入与闹钟输入相比较,组成闹钟功能,以及整点报时功能。源代码Ac.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ac isport(clk,lightonoff:in std_logic;mode,kmode:in std_logic_vector(1 downto 0);csh,csl,cmh,cml,chh,chl,ash,asl,amh,aml,ahh,ahl:in std_logic_vector(3 downto 0);q0,q1,q2,q3,q4,q5,q6,q7:out std_logic_vector(3 downto 0);lightswitch,sound512,sound1024,timeok:out std_logic);end ac;architecture work of ac issignal q0b,q1b,q2b,q3b,q4b,q5b,q6b,q7b: std_logic_vector(3 downto 0);beginprocess(chh,cmh,csh,ash,ahh,amh,chl,cml,csl,asl,ahl,aml,mode,kmode,clk)begin-闪烁功能开始if mode=00 or mode=01 then q0b=csl;q1b=csh;q2b=1010;q3b=cml;q4b=cmh;q5b=1010;q6b=chl;q7b=chh;elsif mode=10 or mode=11 then q0b=asl;q1b=ash;q2b=1010;q3b=aml;q4b=amh;q5b=1010;q6b=ahl;q7b=ahh;end if;if clk =1 then if mode=00 or mode=10 thenq0=q0b;q1=q1b;q2=q2b;q3=q3b;q4=q4b;q5=q5b;q6=q6b;q7q0=1111;q1=1111;q2=q2b;q3=q3b;q4=q4b;q5=q5b;q6=q6b;q7q0=q0b;q1=q1b;q2=q2b;q3=1111;q4=1111;q5=q5b;q6=q6b;q7q0=q0b;q1=q1b;q2=q2b;q3=q3b;q4=q4b;q5=q5b;q6=1111;q7q0=1111;q1=1111;q2=1111;q3=1111;q4=1111;q5=1111;q6=1111;q7=1111;end case;end if;elseq0=q0b;q1=q1b;q2=q2b;q3=q3b;q4=q4b;q5=q5b;q6=q6b;q7=q7b;end if;-闪烁功能完毕-整点报时功能开始if cmh=0101 and cml=1001 thenif csh=0101 thenif csl=0001 or csl=0010 or csl=0101 or csl=0111 thensound512=1 ;elsif csl=1001 thensound1024=1;else sound512=0;sound1024=0;end if;end if;end if;-正点报时功能完毕-显示开关功能开始if lightonoff=1 thenlightswitch=0;else lightswitch=1;end if;-显示开关功能完毕-闹钟功能开始if chh=ahh and cmh=amh and chl=ahl and cml=aml thentimeok=1;elsetimeokqqqqqqqqq=XXXX;end case;end process;end behave;BCD7DIS.vhdlibrary ieee;use ieee.std_logic_1164.all;entity bcd7dis isport(bcdm :in std_logic_vector(3 downto 0);a,b,c,d,e,f,g : out std_logic);end bcd7dis;architecture art of bcd7dis issignal w : std_logic_vector(6 downto 0);beginprocess(bcdm)begina=w(6);b=w(5);c=w(4);d=w(3);e=w(2);f=w(1);gwwwwwwwwwwww= 0000001;end case;end process;end art;SWSC.vHDlibrary ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity swsc isport (en,clk:in std_logic;q: out std_logic_vector(2 downto 0);end swsc;architecture work of swsc isbeginprocess(clk,en)variable x:std_logic_vector(2 downto 0);begin if (clkevent and clk=1) thenif en=1 thenif(x0);end if;end if;end if;q=x;end process;end work;translat38.vhdlibrary ieee;use ieee.std_logic_1164.all;entity translate38 is port(ind:in std_logic_vector(2 downto 0);a,b,c,d,e,f,g,h:out std_logic);end translate38;architecture work of translate38 issignal w :std_logic_vector(7 downto 0);begin process(ind)begina=w(7);b=w(6);c=w(5);d=w(4);e=w(3);f=w(2);g=w(1);hwwwwwwwww= XXXXXXXX;end case;end process;end work;蜂鸣器模块主要功能处理辅控传来的蜂鸣器信号,输出蜂鸣器直接信号。源代码Sound.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity sound isport(clk1,timeok,clk512,clk1024,en512,en1024:in std_logic;ring:out std_logic);end sound;architecture work of sound isbeginprocess(en512,en1024,clk512,clk1024,clk1,timeok)beginif clk512=1 and en512=1 thenring=clk512; elsif clk1024=1 and en1024=1 thenring=clk1024;elsif timeok=1 and clk1=1 thenring=clk1024;elsering=0;end if;end process;end work;分频器模块主要功能系统输入只要求一个1024HZ的脉冲信号,分频器模块将1024HZ分为1HZ,4HZ,512HZ,1024HZ,供各个模块使用。源代码Clkcut.vhdlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity clkcut isport(clk:in std_logic;clk1,clk4,clk512,clk1024:ou

温馨提示

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

评论

0/150

提交评论