1、数字钟数电课程设计报告 JIANGSU TEACHERS UNIVERSITY OF TECHNOLOGY 数字电路课程设计报告(基于FPGA的数字钟设计) 一、课题要求(1) 技术要求 1)掌握QUARTUS-2软件的使用方法;2)具备EDA技术基础,能够熟练使用VHDL语言进行编程,掌握层次化设计方法;3) 掌握多功能数字钟的工作原理,学会不同进制计数器及时钟控制电路的设计方法;4)能根据设计要求对设计电路进行仿真和测试;5)掌握将所设计软件下载到FPGA芯片的下载步骤等等。6) 将硬件与软件连接起来,调试电路的功能。(2) 功能要求基本功能:能进行正常的时、分、秒计时功能,分别由6个数码
2、管显示24小时,60分钟,60秒钟的计数器显示。附加功能:1)能利用硬件部分按键实现“校时”“校分”“清零”功能; 2)能利用蜂鸣器做整点报时:当计时到达5955时开始报时,在5556575859时鸣叫,共鸣叫5秒钟; 3)定时闹铃:本设计中设置的是在六点半时进行闹钟功能,鸣叫时间为一分钟。(3) 本人工作本人主要负责硬件安装及焊接部分!二、设计方案1) 数字钟电路的原理框图详见末页图(a)2) 数字钟设计方案采用同步电路,总线结构。时钟信号分别加到各个模块,各个模块相对独立,模块间连线简单,易于扩展。振荡器和分频器产生稳定的校时信号和计时信号。对“秒”计时信号进行60进制计数,形成“分”计时
3、信号和秒计数值;再对“分”计时信号进行60进制计数,形成“时”计时信号和分计数值;进一步对“时”计时信号进行24进制计数得到时计数值。秒计数值、分计数值和时计数值译码显示时间。3) 数字钟的工作原理数字电子钟由振荡器、分频器 计数器、译码显示、报时等电路组成。振荡器产生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照“24翻1”规律计数。计满后各计数器清零,重新计数。计数器的输出分别经译码器送数码管显示,计时出现误差时,可以用校时电路“校时”“校分”“清零”。秒脉冲可以通过分频电路得到。通过
4、报时设计模块可以实现整点报时及定时闹铃,译码显示由七段译码器完成,显示由数码管构成,采用的是动态显示方式。数码管动态显示:动态扫描电路将计数器输出的8421BGD码转换为数码管需要的逻辑状态,并且输出数码管的片选信号和为选信号。所谓动态扫描显示方式是在显示某一位LED 显示块的数据的时候,让其它位不显示,然后再显示下一位的数据。只要保证每一位显示的时间间隔不要太大,利用人眼的视觉暂留的现象,就可以造成各位数据同时显示的假象。一般每一位的显示时间为110ms。三、单元电路设计及仿真结果与分析(1)分频模块(fenpin)1)程序:library ieee;use ieee.std_logic_1
5、164.all;entity fenpin is port(clk6:in std_logic; q1000,q5,q1:out std_logic);end fenpin;architecture ccc_arc of fenpin issignal x:std_logic;begin process(clk6) variable cnt:integer range 0 to 24999; begin if clk6event and clk6=1 then if cnt24999 then cnt:=cnt+1; else cnt:=0; x=not x; end if; end if;e
6、nd process;q1000=x;process(x)variable cnt2:integer range 0 to 999;variable y:std_logic;begin if xevent and x=1 then if cnt2999 then cnt2:=cnt2+1; q1=0; else cnt2:=0; q1=1; end if; end if;if xevent and x=1 theny:=not y;end if;q5=y;end process;end ccc_arc;2)仿真波形:(2)秒模块(second)1)程序:library ieee;use iee
7、e.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second is port (clk1,en1:in std_logic; qa:out std_logic_vector(3 downto 0); co1:out std_logic; qb:out std_logic_vector(3 downto 0);end second;architecture cc of second issignal cout2,cout1:std_logic_vector(3 downto 0);signal mm: std_logic;b
8、eginprocess(clk1,en1)beginif en1=1 thencout2=0000;cout1=0000;elsif (clk1event and clk1=1)thenif (cout2=5 and cout1=8) then cout2=cout2;cout1=cout1+1;mm=1;elsif (cout2=5 and cout1=9) then cout2=0000;cout1=0000;mm=0;else if (cout1=9) then cout2=cout2+1;cout1=0000;mm=0; else cout2=cout2;cout1=cout1+1;m
9、m=0; end if;end if; end if;end process;co1=mm;qa=cout2;qb=cout1;end cc;2)仿真波形:(3)分模块(minute)1)程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minute is port (clk2,en2:in std_logic; qc:out std_logic_vector(3 downto 0); co2:out std_logic; qd:out std_logic_vector(3 do
10、wnto 0);end minute;architecture bb of minute issignal cout2,cout1:std_logic_vector(3 downto 0);signal cc:std_logic;beginprocess(clk2,en2)beginif en2=1 thenif (clk2event and clk2=1)thenif (cout2=5 and cout1=8) then cout2=cout2;cout1=cout1+1;cc=1;elsif (cout2=5 and cout1=9) then cout2=0000;cout1=0000;
11、cc=0;else if (cout1=9) then cout2=cout2+1;cout1=0000;cc=0; else cout2=cout2;cout1=cout1+1;cc=0; end if;end if;end if; end if;end process;co2=cc;qc=cout2;qd=cout1;end bb2)仿真波形:(4)时模块(hour)1)程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour is port (clk3,en3:in st
12、d_logic; qe:out std_logic_vector(3 downto 0); qf:out std_logic_vector(3 downto 0);end hour;architecture aa of hour issignal cout2,cout1:std_logic_vector(3 downto 0);beginprocess(clk3,en3)beginif en3=1 thenif (clk3event and clk3=1)thenif (cout2=2 and cout1=3) then cout2=0000;cout1=0000;else if (cout1
13、=9) then cout2=cout2+1;cout1=0000; else cout2=cout2;cout1=cout1+1; end if;end if;end if; end if;end process;qe=cout2;qf=cout1;end aa;2)仿真波形:(5)数码显示驱动模块1)程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hhh isport(n1,n2,n3,n4,n5,n6:in std_logic_vector(3 downto 0); a:
14、in std_logic_vector(2 downto 0); qqq:out std_logic_vector(3 downto 0);end hhh;architecture dd of hhh is begin with a selectqqq=n1 when 000, n2 when 001, n3 when 010, n4 when 011, n5 when 100, n6 when 101, 0000 when others;end dd;2)仿真波形: (6)片选模块(sell)1)程序:library ieee;use ieee.std_logic_1164.all;use
15、ieee.std_logic_unsigned.all;entity ggg isport(m:in std_logic_vector(2 downto 0); b:out std_logic_vector(5 downto 0); end ggg;architecture ee of ggg is begin with m selectb=100000 when 000, 010000 when 001, 001000 when 010, 000100 when 011, 000010 when 100, 000001 when 101, 000000 when others;end ee;
16、2)仿真波形:(7)译码显示模块(display)1)程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity decoder isport(x:in std_logic_vector(3 downto 0); y:out std_logic_vector(6 downto 0); end decoder;architecture one of decoder is begin with x selecty=1111110 when 0000, 0110000 when 0001, 11
17、01101 when 0010, 1111001 when 0011, 0110011 when 0100, 1011011 when 0101, 1011111 when 0110, 1110000 when 0111, 1111111 when 1000, 1111011 when 1001, 0000000 when others;end one;2)仿真波形:(8)报时模块(alart)1) 程序:library ieee;use ieee.std_logic_1164.all;entity sst isport(h1,h0,m1,m0,s1,s0:in std_logic_vecto
18、r(3 downto 0);clk4:in std_logic;q500:out std_logic);end sst;architecture sss of sst isbegin process(clk4,m1,m0,s1,s0)beginif (clk4event and clk4=1) then if (h1=0000 and h0=0110 and m1=0011 and m0=0000) or (m1=0101 and m0=1001 and s1=0101 and (s0=0101 or s0=0110 or s0=0111 or s0=1000 or s0=1001)then
19、q500=1; else q500=0;end if;end if;end process;end sss;2) 仿真波形:(9)六进制计数器模块(cnt6)1)程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt6 is port (clk5:in std_logic; n:out std_logic_vector(2 downto 0);end cnt6;architecture behav of cnt6 issignal q1:std_logic_vector(2 d
20、ownto 0);beginprocess(clk5)beginif clk5event and clk5=1 then if q15 then q1=q1+1; else q10);end if;end if; end process;n=q1;end behav;2)仿真波形:(10)两输入与模块(and2a)1)程序:library ieee;use ieee.std_logic_1164.all;entity anda isport (a1,b1:in std_logic; y:out std_logic);end anda;architecture an of anda isbegi
21、ny=a1 and b1;end an;2)仿真波形:(11)两输入或模块(or2a)1)程序:library ieee;use ieee.std_logic_1164.all;entity or_1 isport (a1,b1:in std_logic; y:out std_logic);end or_1;architecture oo of or_1 isbeginyclk,q1=h,q1000=z);u2:second port map(clk1=h,en1=sc,qa=k,qb=l,co1=I);u0:or_1 port map(a1=i,b1=sb,y=a);u3:minute po
22、rt map(clk2=h,en2=a,qc=e,qd=f,co2=j);u30:anda port map(a1=i,b1=j,y=b);u31:or_1 port map(a1=b,b1=sa,y=c);u4:hour port map(clk3=h,en3=c,qe=u,qf=v);u5:sst port map(h1=u,h0=v,m1=e,m0=f,s1=k,s0=l,clk4=h,q500=q1);u6:hhh port map(n1=k,n2=l,n3=e,n4=f,n5=u,n6=v,qqq=t,a=s);u7:ggg port map(b=r,m=s);u8:cnt6 por
23、t map(n=s,clk5=z);u9:decoder port map(x=t,y=q0);end architecture main;2) 仿真波形:五、硬件电路设计与安装电路(1) 按照电路功能设计好硬件部分安装图(电路安装图详见末页图b);(2) 根据电路板的大小以及所有的元器件,大致决定好各元器件的分布情况。注:布线不能有交叉线,且要注意工艺问题即布线要讲究横平竖直原则。(3) 先把数码管底座插到板子上,把各个数码管之间相连接起来需要的导线准备好,用胶带贴在板子上固定好;然后再逐步增加元器件,用同样的方法布好线固定好。注:必须清楚共阴极数码管的各引脚以及三极管的引脚。(4) 接下来就是焊接部分,把导线引脚都焊接到板子上。也可以在布线的过程中排好一部分线就焊接一部分,分步来。注:我的烙铁功率(30W)较大,焊接过程中必须快、狠、准,烙铁与焊盘接触时间不能太长否则焊盘容易脱落。(5) 由于我们需要六个数码管,相对来说,线路比较复杂,布线比较容易有交叉线,所以,不好布线的部分可以充分利用杜邦线的作用,这样电路板布局比较清楚,导线分布也比较美观。(6) 电路焊接好后,对照电路图检查一下电路。确定电路无误后才能连接芯片调试功能。注:硬件电路和芯片连接时要仔细,注意程序
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1