EDA课程设计——多功能数字钟课程设计报告_第1页
EDA课程设计——多功能数字钟课程设计报告_第2页
EDA课程设计——多功能数字钟课程设计报告_第3页
EDA课程设计——多功能数字钟课程设计报告_第4页
EDA课程设计——多功能数字钟课程设计报告_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、多功能数字电子钟一、 设计要求1、 具有以二十四小时计时、显示、整点报时、时间设置和闹钟的功能。2、 设计精度要求为 1S。二系统功能描述1 . 系统输入:系统状态及校时、定时转换的控制信号为k、 mode、 set;时钟信号elk,采用1024Hz ;系统复位信号为reset。输入信号均由按键产生。系统输出: LED 显示输出,蜂鸣器声音信号输出。 多功能数字钟系统功能的具体描述如下:2. 计时:正常工作状态下,每日按 24h 计时制计时并显示,蜂鸣器无声,逢整点报时。3. 校时:在计时状态显示下,按下“ set键”进入“小时”校准状态,之后按下“ k键”则进入“分”校准状态, 继续按下“

2、k 键”则进入“秒复零”状态,第三次按下“ k 键”又恢复到正常计时显示状态。1) “小时”校准状态:在“小时”校准状态下,显示“小时”数码管以1Hz 的频率递增计数。2) “分”校准状态:在“分”校准状态下,显示“分”的数码管以1Hz 的频率递增计数。3) “秒”复零状态:在“秒复零”状态下,显示“秒”的数码管复零。4. 整点报时:蜂鸣器在“ 59”分钟的第“ 51 ”、“ 53 ”、 “ 55”、 “ 57秒发频率为 512Hz 的低音,在“ 59”分钟的第“ 59 ”秒发频率为 1024Hz 的高音,结束时为整点。5. 显示:要求采用扫描显示方式驱动 6个 LED 数码管显示小时、分、秒

3、。闹钟:闹钟定时时间到,蜂鸣器发出周期为1s的“滴”、“滴”声,持续时间为 10s;闹钟定时显示。6. 闹钟定时设置:在闹钟定时显示状态下,按下“set键”,进入闹钟的“时”设置状态,之后按下“k键”进入闹钟的“分”设置状态,继续按下“ k 键”则进入“秒”设置状态,第三次按下“ k 键”又恢复到闹钟定时显 示状态。1) 闹钟“小时”设置状态:在闹钟“小时”设置状态下,显示“小时”的数码管以1Hz 的频率递增计数。2) 闹钟:“分”设置状态:在闹钟“分”设置状态下,显示“分”的数码管以1Hz 的频率递增计数。三、 控制器的 MDS 图及多功能数字系统结构逻辑框图1、 控制器的 MDS 图Mod

4、e=1,set=0K=1K=1S0:S4:显示计时时间显示闹铃时间si:调计时的时 s2:调计时的分 s5:调闹铃的时 s6:调闹铃的分s3:调计时的秒s7:调闹铃的秒2、 多功能数字系统结构逻辑框图:4 AftC/itCn kMlfllTN1I3TM>I3riK3>/na/>C3»/>!3N1C3>M1I3MIC 3TXNC. "MAMIC 3M>C3NIK 3N>C3>M>I3NIC 3/1C3>Mlt3NIC 3r&c a>M>I3LXNCC3CLKFLA/MXgY1FLA/WMIMfiF

5、LA/HMIIIIIIIIICOHOU1/N«Udoc no.»1C3* 43&>C 0,»3C3* gDOC 43»KC3- g»rca* 0,&1C3- gCHx r« ”x r« ”四、各功能模块设计说明及源程序1、控制器: 设计说明:根据外部的输入控制信号,完成各个状态之间的转换,并在相应状态输出相应的控 制信号,从而对整个系统的工作进行控制。控制器:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;ent

6、ity contl is port(clk,reset,k,set:in std_logic; cht,cmt,cst,cha,cma,csa,flashh,sel_showflashm,flashs:out std_logic); end contl;architecture ar of contl istype state_type is(s0,s1,s2,s3,s4,s5,s6,s7); signal state:state_type;begin process(clk,reset,k,set)begin if(rising_edge(clk)then if(reset='1&#

7、39;)then state<=s0;end if;case state iswhen s1=>sel_show<='1' cht<='1'flashh<='1' if(k='1')then state<=s2;else state<=s1;end if;when s2=>sel_show<='1' cmt<='1'flashm<='1'if(k='1' )then state<=s3; else

8、 state<=s2; end if;when s3=>sel_show<='1' cst<='1'flashs<='1'if(k='1' )thenstate<=s0;else state<=s3;end if;when s4=>sel_show<='0' if(k='0' and set='1')then state<=s5;elsif(k='1' and set='0')then sta

9、te<=s0;else state<=s4;end if;when s5=>sel_show<='0' cha<='1'flashh<='1' if(k='1')then state<=s6;else state<=s5;end if;when s6=>sel_show<='0' cma<='1'flashm<='1' if(k='1' )then state<=s1;else state&

10、lt;=s0;end if;when s7=>sel_show<='0' csa<='1'flashs<='1' if(k='0' and set='1')then state<=s4;else state<=s7;end if;when s0=>sel_show<='1' if(k='0' and set='1')then state<=s1;elsif(k='1' and set='0&

11、#39;)then state<=s4;else state<=s0;end if;end case;end if;end process;end ar;2、计时校时电路: 设计说明:该电路实现计时、校时功能 源程序:1他丫3Den"TO""24 I二十四进制计数器: 源程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity m24 is port(en,clk : in std_logic;p0,p1 :out std_logic_vector(

12、3 downto 0); end m24;architecture ar of m24 is signal q0,q1:integer range 0 to 15; beginprocess(clk)beginif (rising_edge(clk) thenif (en='0' or (q0=3 and q1=2) then q0<=0; q1<=0;elsif(q0=9) thenq0<=0; q1<=q1+1;else q0<=q0+1;end if;end if;p0<= conv_std_logic_vector(q0,4); p1

13、<= conv_std_logic_vector(q1,4); end process;end ar;六十进制计数器: 源程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity m60 is port(en,clk : in std_logic; x: out std_logic;p0,p1:out std_logic_vector(3 downto 0); end m60;architecture ar of m60 is signal q0,q1:integer range 0

14、to 15;begin process(clk) begin if (rising_edge(clk) then if (en='0' or (q0=9 and q1=5) then q0<=0; q1<=0; x<='1' elsif(q0=9) thenq0<=0; q1<=q1+1;else q0<=q0+1;x<='0'end if;end if;p0<= conv_std_logic_vector(q0,4);p1<= conv_std_logic_vector(q1,4);end

15、process;end ar; 选择器源程序: library ieee;use ieee.std_logic_1164.all;entity conl isport(f1,f4,c: in std_logic;f :out std_logic);end conl;architecture ar of conl isbeginprocess(c,f1,f4)begin if(c='0')thenf<=f1;else f<=f4;end if;end process;end ar;3、显示控制电路: 设计说明:该模块控制最终显示的计时时间还是闹铃时间。 源程序: li

16、brary ieee;use ieee.std_logic_1164.all;entity show_con isport(ts1,ts2,tm1,tm2,th1,th2,bs1,bs2,bm1,bm2,bh1,bh2:in std_logic_vector(3 downto 0); s1,s2,m1,m2,h1,h2,line:out std_logic_vector(3 downto 0);sel_show ,clk,flashs,flashm,flashh:in std_logic);end show_con;architecture ar of show_con issignal q:

17、integer range 0 to 1;begin process(clk) begin if(rising_edge(clk)then q<=q+1;if(flashh='1'and q=1)thenh1<="1111"h2<="1111" elsif(flashm='1'and q=1)then m1<="1111"m2<="1111"elsif(flashs='1'and q=1)thens1<="1111&quo

18、t;s2<="1111" elseif(sel_show='1' )thens1<=ts1;s2<=ts2;m1<=tm1;m2<=tm2;h1<=th1;h2<=th2;elses1<=bs1;s2<=bs2;m1<=bm1;m2<=bm2;h1<=bh1;h2<=bh2;end if;end if;end if;line<="1110"end process;end ar;4、定时比较电路:设计说明 :包含两个模块,定时模块和比较模块;完成定时时间的设

19、定、定时时间的输出、计时 时间与定时时间比较并输出相应的比较结果控制蜂鸣器的工作,从而实现闹铃功能。 比较模块源程序: library ieee;use ieee.std_logic_1164.all;entity com_t_d isport(clk : in std_logic;comout: out std_logic;th1,th2,tm1,tm2,ts1,ts2,h1,h2,m1,m2:in std_logic_vector(3 downto 0); bh1,bh2,bm1,bm2,bs1,bs2:out std_logic_vector(3 downto 0);end com_t_

20、d;architecture ar of com_t_d isbeginprocess(clk)beginif(rising_edge(clk)thenif(th1=h1 and th2=h2 and tm1=m1 and m2=tm2)then comout<='1'bh1<= th1;bh2<= th2;bm1<= tm1;bm2<= tm2;bs1<= ts1;bs2<= ts2;else comout<='0' bh1<= th1; bh2<= th2;bm1<= tm1; bm2<

21、= tm2;bs1<= ts1;bs2<= ts2;end if;end if;end process;end ar;定时模块逻辑框图:总图:41C$B曰in日mhdEM SHIES.BFfll BHE3U DCHA Ell丄】3. » SCMA BH23.-0CSA B£l3.0J酣貳MQahi 丽 r理g 、«nipjUFUT _11 vm. mr8,L1wc- Lrmr"LICOM.T DCLKTH13.THE3iOGOtlQUTTI11 3 .> 0J 0TH2 3 .1BHZ3.a0BMJL3. , 0'TS3 3.r

22、 WBM£3a,0Jnxii6 “ QHZ.0£3 u 00I12 3.0WITT'gEUT T5、报时闹铃电路:设计说明:该模块整点报时和闹铃输出。源程序:library ieee;use ieee.stdo gic_1164.all;en tity bel isport(m1,m2,s1,s2:in stdogic_vector(3 downto 0);bell:out std_logic;compout,f512,f1024,clk,k:in std_logic);end bel;architecture ar of bel isbeg inprocess(m

23、1,m2,s1,s2,compout,clk)beg inif(risi ng_edge(clk)the nif(k='1')the nif(compout='1') then bell<=f1024;elsif(m 仁"0101" a ndm2="1001" a nd s仁"0101"a nds2="0001")the n bell<=f512;elsif( m仁"0101" a ndm2="1001" a nd s仁"

24、0101"a nds2="0011")then bell<=f512;elsif( m仁"0101" a ndm2="1001" a nd s仁"0101"a nds2="0101")then bell<=f512;elsif( m仁"0101" a ndm2="1001" a nd s1="0101"a nds2="0111")then bell<=f512;elsif(m1="

25、;0101" and m2="1001" and s1="0101" and s2="1001" )then bell<=f512;else bell<=clk;end if;else bell<=clk;end if;end if;end process;end ar;6、动态显示电路:设计说明:该模块由一个八选一选择器、一个模 8 计数器、一译码驱动电路组成。用于控制显 示正常计时时间或闹铃时间。源程序:八选一模块:library ieee;use ieee.std_logic_1164.all;ent

26、ity mux8to1 isport (d0,d1,d2,d3,d4,d5,d6,d7: in std_logic_vector(3 downto 0);a :in std_logic_vector(2 downto 0);q : out std_logic_vector(3 downto 0);end mux8to1;architecture ar of mux8to1 isbeginprocess(d0,d1,d2,d3,d4,d5,d6,d7,a)begin case a is when"000"=>q<=d0;when"001"=&g

27、t;q<=d1;when"010"=>q<=d2;when"011"=>q<=d3;when"100"=>q<=d4;when"101"=>q<=d5;when"110"=>q<=d6;when"111"=>q<=d7;when others=>q<="XXXXXXXX"end case;end process;end ar;模八计数器:library ieee;us

28、e ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity m8 is port(en,clk : in std_logic;q :out std_logic_vector(2 downto 0); end m8;architecture ar of m8 issignal q0 :integer range 0 to 10; beginprocess(clk)beginif (rising_edge(clk) thenif (en='0' or q0=7) thenq0<=0;else q0<=q0+

29、1;end if;end if;q<= conv_std_logic_vector(q0,3);end process;end ar; 译码驱动电路 library ieee;use ieee.std_logic_1164.all;entity tra4to8 isport ( a :in std_logic_vector(3 downto 0); q : out std_logic_vector(6 downto 0);end tra4to8;architecture ar of tra4to8 is begin process(a) begin case a is when"

30、;0000"=>q<="1111110" when"0001"=>q<="0110000" when"0010"=>q<="1101101" when"0011"=>q<="1111001" when"0100"=>q<="0110011" when"0101"=>q<="1011011" whe

31、n"0110"=>q<="0011111" when"0111"=>q<="1110000" when"1000"=>q<="1111111" when"1001"=>q<="1110011" when"1111"=>q<="0000000" when"1110"=>q<="0000001&quo

32、t; when others=>q<="XXXXXXX" end case;end process;end ar;231230计时校时电路Name:Value:11cst00i-fl各个大模块的防真图 一)、控制器800.0 ns1 .Bus 2.4us3.2us4. Ous4. Bus6.6 us B.4us7.2 usS.Ous 9.Sua 9.6lcht證h23. 02 s23.O -lv s1 3.0 -z m23. 0 冠f m1|3 0 »hip.O 抄 |m24:2|p0 抄 |m24:2|p1 抄 |m24:2|c|0 謝 |m24:2|q1 抄 |m60:21|pQ 抄 |m60;21|p1 抄 |m60:21|q0 M |m6O:21|q1 抄 |mE0:24|p0 Qjk |m60;24|p1 則 |m60:24|(0i-turviin 4.>i jaiffiiiSO On? IBO.lln? 24D Ons320,0n?400.0ns 400 Qns£40 Qus 720.0ns300.0ns SSQ.Qn;960.DnName:Value.,J石set0rasel1k0elk-tdi* sel_show0flighs0flashm0fl斡hhcstc-&

温馨提示

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

评论

0/150

提交评论