基于FPGA的电子时钟设计(共21页).doc

上传人:飞****2 文档编号:14232704 上传时间:2022-05-03 格式:DOC 页数:21 大小:598KB
返回 下载 相关 举报
基于FPGA的电子时钟设计(共21页).doc_第1页
第1页 / 共21页
基于FPGA的电子时钟设计(共21页).doc_第2页
第2页 / 共21页
点击查看更多>>
资源描述

《基于FPGA的电子时钟设计(共21页).doc》由会员分享,可在线阅读,更多相关《基于FPGA的电子时钟设计(共21页).doc(21页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、精选优质文档-倾情为你奉上Civil Aviation University of China电子技术应用设计报告基于FPGA的电子时钟设计专 业: 通信工程 学 号: xxxxxxx 学生姓名: xxx 所属学院: 电信学院 任课教师: xxx 摘要本设计采用EDA技术,采用原理图和硬件描述语言VHDL混合编程设计时钟逻辑系统,在QuartusII5.0工具软件环境下,采用自顶向下的设计方法,由各个基本模块共同构建了一个基于FPGA的电子时钟。本时钟系统主芯片采用EP1C6Q240C8N,具有显示时间、日期、时间及日期校准、整点报时、定时闹钟等功能。其中时间采用24小时循环计数,日期计数器具

2、有闰年、月大、月小的判断并准确计数功能。通过按键控制可以实现:日期和时间的切换显示、日期和时间的校准、闹钟的开关控制。关键词 :FPGA;电子时钟;原理图;VHDL语言;AbstractIn my design EDA technology is used, and I designed the clock logic system by means of schematic and VHDL hardware description language. Under QuartusII5.0 Tools software environment, I used the top-down des

3、ign methodology, where various basic modules work together to build a FPGA-based electronic clock.The main chip of the clock system is EP1C6Q240C8N, which has the function of time display, date display, time and date calibration, the whole point of time, and regular alarm clock. Furthermore, 24-hour

4、 cycle, date counter which time has leap-year, month, a small months judgment and accurate counting function are designed. What we can achieve through the control buttons are as follows: switching the display of date and time, calibration of date and time, and the alarm switch control.Keywords: FPGA

5、; electronic clock; schematic; VHDL language;目录基于FPGA的电子时钟设计1.FPGA介绍FPGA(FieldProgrammable Gate Array),即现场可编程门阵列,它是在PAL、GAL、CPLD等可编程器件的基础上进一步发展的产物。它是作为专用集成电路(ASIC)领域中的一种半定制电路而出现的,既解决了定制电路的不足,又克服了原有可编程器件门电路数有限的缺点。FPGA采用了逻辑单元阵列LCA(Logic Cell Array)这样一个概念,内部包括可配置逻辑模块CLB(Configurable Logic Block)、输出输入模块

6、IOB(Input Output Block)和内部连线(Interconnect)三个部分。 现场可编程门阵列(FPGA)是可编程器件。与传统逻辑电路和门阵列(如PAL,GAL及CPLD器件)相比,FPGA具有不同的结构,FPGA利用小型查找表(161RAM)来实现组合逻辑,每个查找表连接到一个D触发器的输入端,触发器再来驱动其他逻辑电路或驱动I/O,由此构成了既可实现组合逻辑功能又可实现时序逻辑功能的基本逻辑单元模块,这些模块间利用金属连线互相连接或连接到I/O模块。FPGA的逻辑是通过向内部静态存储单元加载编程数据来实现的,存储在存储器单元中的值决定了逻辑单元的逻辑功能以及各模块之间或模

7、块与I/O间的联接方式,并最终决定了FPGA所能实现的功能,FPGA允许无限次的编程。2电子时钟的设计方案2.1时钟系统整体介绍本时钟系统主要由分频器模块、计数模块、译码模块、显示模块、校时模块以及闹钟模块构成。由分频器从48MHZ晶振中得到1HZ信号给计数器提供标准时钟,译码器将计数器数据译码数码管能显示的信号,显示模块扫描译码器数据并显示。由于计数的起始时间不可能与标准时间(如北京时间)一致,故需要在电路上加一个校时电路,同时标准的1HZ时间信号必须做到准确稳定。系统框图如下:按键分频器按键晶振期计数器时间计数器闹钟译码器显示模块图2-1时钟系统框图2.2分频器本分频器采用偶数分频,使占空

8、比达到50%很简单,只要使用一个计数器,在计数器的前一半时间里,使输出电平低电平,在计数器的后一半时间里,使输出电平为低电平,这样输出的时钟信号就是占空比为50%的偶数分频时钟信号。图2-2-1分频器电路设计本分频器有48分频、100分频、10分频三个程序模块构成,输入48MHz,输出1KHz、100Hz、1Hz时钟信号。由于本分频器的判断条件为if count cal_out =data_in; time_out time_out =data_in; cal_out=;END CASE;END PROCESS;END ARCHITECTURE;这样就使得当控制按钮按下时,通过显示模块切换显示

9、画面,同时按键分别控制时间计数模块和日期计数模块。2.8闹钟模块闹钟模块由整点报时和定时闹钟两部分组成。图2-8-1整点报时模块当时计数器进位时,进位信号被取出送到蜂鸣器控制端,控制端使能输入1KHz信号到蜂鸣器,这样就到达整点报时功能。图2-8-2定时闹钟模块为了便于演示本闹钟模块定时时间为10秒,具有开启和关闭功能。当按键按下时T触发器翻转,使能计数器,当计数器计满10秒时进位使能蜂鸣器实现闹钟效果。当再次按下按键,T触发器再次翻转,计数器关闭,闹钟关闭。3实习总结3.1本系统的优点1. 分频器实现容易,可以任意分频,连线少。2. 时间计数器和日期计数器具有校准信号输入端,能实现校时和重启

10、功能3. 日期计数器能准确的实现闰年、闰月、月大、月小的计数4. 译码器具有灵活性,不受器件限制,可以任意译码,实现自己想要的效果。3.2本系统的不足1. 分频器具有局限性,不能很好的对奇数个脉冲进行分频。2. 进位信号与归零信号不能同步。计数器计满归零时,进位信号不能立即进位,要晚一个时钟信号。3. 校时操作比较繁琐。首先是控制按键比较多,然后是校准时间时,需要等到秒时钟信号到来时计数器才会加一或减一,使得校准时间比较慢。4. 闹钟不能设定,为了便于演示,只做了一个10秒计数器。3.3想实现却又没实现的功能1. 对时间进行校准时,由于受秒时钟限制,校准操作比较慢。因此尝试过以下两种方案:i.

11、 输入1Hz、2Hz两个时钟信号,1Hz信号用于计数器计数,2Hz信号用于校准时间,但是程序老是报错,实验失败。ii. 校准信号不受时钟信号控制,当按键按下时,就使计数器加一或减一。由于按键消抖不是很好,每按下一次按键,计数器增加几十位,不是预期效果,实验失败。2. 闹钟模块有两个预想功能没有实现:i. 定时时间可以设定。ii. 闹钟工作时播放一首歌曲。失败原因:1.时间不足;2.对电子琴不了解,要完成电子琴模块,需要大量时间。附录1:分频器以下是100分频程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.

12、all;use ieee.std_logic_unsigned.all;entity divider100 isGENERIC (N:integer:=100);port (clk:in std_logic;outclk:out std_logic);end divider100;architecture one of divider100 issignal count:integer;beginprocess(clk)beginif(clkevent and clk=1) thenif(count=N-1)thencount=0;elsecount=count+1;if count(inte

13、ger(N/2) thenoutclk=0;elseoutclk=1;end if;end if;end if;end process;end one;附录2:时间计数器附录2.1:六十进制计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second isport(enl,res,clk,sadd,sdec:in std_logic; a,b:out std_logic_vector(3 downto 0); ca:out std_logic);end second;-enl使

14、能 -res清零-clk时钟-sadd加-sdec减-a低位-b高位-ca进位architecture SEC of second isbeginprocess(enl,clk,res)variable m0,m1:std_logic_vector(3 downto 0);beginif res=1 then m0:=0000; m1:=0000; ca=0; elsif clkevent and clk=1 then ca=0; if sadd=1 or enl=1 then if m0=1000 and m1=0101 then ca=1; -实际是第59个-脉冲 end if; if m

15、00101 then m0:=0000; m1:=0000; ca0000 then m0:=m0-1; else m0:=1001; m1:=m1-1; end if; end if; end if; a=m0;b=m1;end process;end SEC;附录2.1:二十四进制计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport(enl,res,clk,hadd,hdec:in std_logic; a,b:out std_logic_vector(3

16、 downto 0); ca:out std_logic);end hour;-enl使能 -res清零-clk时钟-hadd加-hdec减-a低位-b高位-ca进位architecture SEC of hour isbeginprocess(enl,clk,res)variable m0,m1:std_logic_vector(3 downto 0);beginif res=1 then m0:=0000; m1:=0000; ca=0; elsif clkevent and clk=1 then ca=0; if hadd=1 or enl=1 thenif m0=0011 and m1

17、=0010 then ca=1; m0:=0000; m1:=0000; end if; if m00000 then m0:=m0-1; else m0:=1001; m1:=m1-1;end if; end if; end if; a=m0;b=m1;end process;end SEC;附录3:日期计数器附录3.1:天计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity day isport(enl,res,clk,dadd,ddec:in std_logic; sel:in

18、 std_logic_vector(2 downto 0); a,b:out std_logic_vector(3 downto 0); ca:out std_logic);end day;-sel0-year-0表示闰年-sel1-month,1表示4,6,9,11-0表示1、2、3、5、7、8、10、12-sel2-Feb,1表示2月architecture SEC of day issignal sr0,sr1:std_logic_vector(3 downto 0);beginprocess(sel)beginif sel=001 or sel=000 then sr0=0001; s

19、r1=0011;-31elsif sel=100 then sr0=1001; sr1=0010;-29elsif sel=101 then sr0=1000; sr1=0010;-28else sr0=0000; sr1=0011;-30end if;end process;process(enl,clk,res)variable r0,r1:std_logic_vector(3 downto 0);beginif res=1 then r0:=0001; r1:=0000; ca=0; elsif clkevent and clk=1 then ca=0; if dadd=1 or enl

20、=1 then if r0=sr0 and r1=sr1 then r0:=0001; r1:=0000; ca=1; elsif r01001 then r0:=r0+1; ca0000 then r0:=r0-1; else r0:=1001; r1:=r1-1; end if; end if; end if; a=r0;b=r1;end process;end SEC;附录3.2:月计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity month isport(enl,res,

21、clk,madd,mdec:in std_logic; a,b:out std_logic_vector(3 downto 0); ermonth,msel,ca:out std_logic);end month;-ermonth connect to sel2-msel connect to sel1architecture SEC of month isbeginprocess(enl,clk,res)variable y0,y1:std_logic_vector(3 downto 0);beginif res=1 then y0:=0001; y1:=0000; ca=0; elsif

22、clkevent and clk=1 then ca=0; if madd=1 or enl=1 then if y0=0010 and y1=0001 then y0:=0001; y1:=0000; ca=1; elsif y01001 then y0:=y0+1; ca0000 then y0:=y0-1; else y0:=1001; y1:=y1-1; end if; end if; end if;if (y0=0100 or y0=0110 or y0=1001 ) and y1=0000)or (y0=0001 and y1=0001) then msel=1; else mse

23、l=0;end if;if y0=0010 and y1=0000 then ermonth=1; else ermonth=0;end if; a=y0;b=y1;end process;end SEC;附录3.3:年计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity year isport(enl,res,clk,yadd,ydec:in std_logic; a,b,c,d:out std_logic_vector(3

24、 downto 0); ysel:out std_logic);end year;-ysel connect to sel0architecture nd of year isbegin process(res,enl,clk)variable n0,n1,n2,n3:std_logic_vector(3 downto 0);begin if res=1 then n0:=0010;n1:=0001;n2:=0000;n3:=0010; elsif clkevent and clk=1 then if yadd=1 or enl=1 then if n00000 then n0:=n0-1 ;

25、 elsif n0=0000 and n1=0000 and n2=0000 and n3=0000 then n0:=1001; n1:=1001; n2:=1001; n3:=1001; elsif n0=0000 and n1=0000 and n2=0000 then n0:=1001; n1:=1001; n2:=1001; n3:=n3-1; elsif n0=0000 and n1=0000 then n0:=1001; n1:=1001; n2:=n2-1; elsif n0=0000 then n0:=1001; n1:=n1-1; end if; else n3:=0010

26、; end if; if (n0(0)=0 and n0(1)=0 and n1(0)=0)or(n0(0)=0 and n0(1)=1 and n1(0)=1) then ysel=0; else ysel=1;end if;end if;a=n0;b=n1;c=n2;d data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out data_out =;-3)规划实施的经济效益、社会效益与环境效益之间以及当前利益与长远利益之间的关系。END CASE;END PROCESS;(二)安全评价的基本原则END ARCHITECTURE;专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

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

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com