毕业设计(论文)基于CPLD的数字频率计的设计.doc

上传人:仙人指路1688 文档编号:3979040 上传时间:2023-03-30 格式:DOC 页数:27 大小:6.45MB
返回 下载 相关 举报
毕业设计(论文)基于CPLD的数字频率计的设计.doc_第1页
第1页 / 共27页
毕业设计(论文)基于CPLD的数字频率计的设计.doc_第2页
第2页 / 共27页
毕业设计(论文)基于CPLD的数字频率计的设计.doc_第3页
第3页 / 共27页
毕业设计(论文)基于CPLD的数字频率计的设计.doc_第4页
第4页 / 共27页
毕业设计(论文)基于CPLD的数字频率计的设计.doc_第5页
第5页 / 共27页
点击查看更多>>
资源描述

《毕业设计(论文)基于CPLD的数字频率计的设计.doc》由会员分享,可在线阅读,更多相关《毕业设计(论文)基于CPLD的数字频率计的设计.doc(27页珍藏版)》请在三一办公上搜索。

1、基于CPLD的数字频率计的设计 摘 要 频率是电子技术中最基本的参数之一,与其他电参量的测量方案及结果关系非常密切。其中数字频率计在各方面领域都有很广泛的运用,随着科技的发展与生活的提高,数字频率计的需求也将大大提升。目前直接测频方法有两种:测频法和测周期法。测频法是在确定的时间Tw内,记录被测信号的变化周期数Nx,则测得的频率为:fx=Nx/Tw。测周期法需有标准信号频率fs,在待测信号的一个周期Tx内,记录标准频率的周期数。则测得的频率为:fx=fs/Ns 。本课题主要选择以CPLD为核心器件,VHDL为编程语言,采用测频法设计一个简单实用的数字频率计,以计数器、译码器为核心,由内部分频输

2、入信号、信息锁存、数字显示等功能模块组成,可以实现简单的频率测量。关键词 CPLD,频率计,计数,仿真波形ABSTRACTFrequency of electronic technology in one of the most basic parameters, and other electrical parameters and results of the measurement scheme very closely.In which all aspects of digital frequency meter in the field have a very widely used

3、, with the development of technology and life improved, the demand for digital frequency meter will also be greatly enhanced.Direct measurement of the current frequency in two ways: frequency measurement method and test cycle method. Frequency measurement method is in determining the time Tw, the re

4、cord number of cycles the signal changes in Nx, then the measured frequency is: fx = Nx / Tw. The need for standard test cycle approach signal frequency fs, a cycle in the Tx signal under test, The recorded number of cycles the standard frequency. The measured frequency is: fx = fs / Ns. The main su

5、bject chosen as the core device CPLD, VHDL as a programming language, frequency measurement method using a simple and practical design of digital frequency meter to counter, decoder core, from the inner part of the frequency of the input signal, the information is latched, figures show other functio

6、nal modules, a simple frequency measurement can be achieved.Key Words:CPLD Frequency Counter Count Simulation waveform目 录一、 绪 论11.1 课题背景及其意义11.1.1 设计背景11.1.2 设计目标11.1.3 设计意义11.2 设计思路21.2.1 软件方面21.2.2 硬件方面21.3 数字频率计的发展21.3.1 数字频率计的分类31.4 数字频率计的相关概念41.5 数字频率计实现的主要方法5二、 设计内容7三、 设计方案步骤83.1 信号输入83.2 时基控制

7、模块83.3 分频器模块93.4 计数器模块93.5 锁存器模块103.6 译码器模块113.7 调试113.7.1 软件调试113.7.2 硬件调试11四、 设计总结13五、 参考文献14六、 附 录156.1 附录1 总电路图156.2 附录2 程序代码156.2.1 时基控制模块程序代码156.2.2 分频器模块程序代码166.2.3 计数器模块程序代码186.2.4 锁存器模块程序代码196.2.5 译码器模块程序代码206.2.6 顶层文件程序代码216.3 附录3 实物图22七、 答 谢23一、 绪 论1.1 课题背景及其意义1.1.1 设计背景转眼间大学的学习生涯即将结束,为了检

8、验对这四年所学知识掌握运用的程度,针对电子信息专业课程的要求,培养出能利用所学理论知识与实践相结合,能独立思考,锻炼动手等方面的能力,基于个人爱好及所掌握的知识,本设计选择基于CPLD的数字频率计的设计。1.1.2 设计目标(1)频率测量范围:19999Hz。(2)输入被测信号幅度Vi100mV。(3)测量1s时间内的脉冲数。(4)测量误差编译,提示没有错误后便可以仿真了。 2.新建波形文件,进入操作界面,先点击edict菜单,设置 end time ,一般情况大概设为10us,由于软件本身的缘故,end time值不应该设的太小,否则延时会很大,影响效果。3.7.2 硬件调试 软件仿真无误后

9、,就可以与硬件相连。在这之前的先设置好管脚。点击“assingmengt”菜单的“pin planner”把管脚设置好,确定无误后编译。关闭puartus软件,将频率计接入电脑,按提示安装。重新打开软件,点击菜单“tools”中的”granmmer”确定接好USB接口。调试结果如图3-9,图3-10和图3-11所示,分别表示测得的频率为128Hz、512Hz和1024Hz:图3-9图3-10图3-11四、 设计总结此次选择基于CPLD的数字频率计毕业设计的初衷是:之前也学习接触了与CPLD相关的基础知识,但是自己设计实际动手起来的条件是没有的,本人也对CPLD方面的设计比较感兴趣,所以想通过此

10、次毕业设计锻炼自己的动手能力,更好的把理论知识与实践联系起来,巩固、加深个人对电子设计方面的兴趣。设计过程中使用了 Quartus II软件。这个软件前几年已经学习使用过但还不是很熟练,通过老师与同学多次指导,经过多次反复操作最终基本掌握了它的使用方法。使我更加熟练掌握了编辑输入图形设计文件、编译设计文件、仿真设计文件及编程下载设计文件等各种不同的文件设计。因为各种原因,我们设计之前准备确实不是很充足,包括心理上还有自身能力上,所以自然的就造成了把时间花费在许多不必要的事情上,我建议以后学校能够在课堂外利用更多时间培训同学们相关的实践动手能力,让同学们提前有所准备,更加透彻学习与了解专业相关的

11、知识与技能,相信同学们再次接触到设计之类时就不会忙手忙脚的了。总的来说通过这次毕业设计让我更加深刻的明白,理论上的知识与实际情况总是相差比较大的,做任何事情都不能想这是理所当然的,要通过自己亲身体会才能明白其中的奥秘。五、 参考文献1. 阎石主编,数字电子技术基础(第五版),高等教育出版社。3. 曹昕燕,周凤臣,聂春燕编著,EDA技术实验与课程设计,清华大学出版社。4. 彭介华主编,电子技术课程设计指导,高等教育出版社。5. 张 原编著,可编程逻辑器件设计及应用,机械工业出版社。6. 荀殿栋,徐志军编著,数字电路设计实用手册,电子工业出版社。7. 潘松、黄继业编著,EDA技术实用教程(第三版)

12、,科学出版社。8. 刘洪喜,陆颖编著,VHDL电路设计实用教程,清华大学出版社。9. 付家才主编,EDA工程实践技术,化学工业出版社。六、 附 录6.1 附录1 总电路图总体电路如图6-1所示:图6-1 总体电路图6.2 附录2 程序代码6.2.1 时基控制模块程序代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ctrl isport(clk:in std_logic;lock:out std_logic;en: out std_logic;clr: out std_logic)

13、;end;architecture art of ctrl issignal q :std_logic_vector(3 downto 0);beginprocess(clk)beginif clkevent and clk=1 thenif q=1111 then q=0000; else q=q+1;end if;end if;en=not q(3);lock=q(3) and not(q(2) and q(1);clr=q(3) and q(2) and not(q(1);end process;end art;6.2.2 分频器模块程序代码(FPQ部分):Library ieee;Us

14、e ieee:std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity fpq isPort(clk_32mhz:in std_logic;Clk_1hz:out_std_logic);end;Architecture one of fpq isbeginProcess(clk_32mhz)variable r:std_logic :=0;Variable q: ubteger :=0;beginIf clk_32mhzevent and clk_32mhz=1 thenIf q=2097151 then r:=not r;q:=0;E

15、lse q:=q+1;end if;clk_1hz=r;end if;End process;End one;(FPQ128部分):Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity fpq_128 isport(clk_32mhz:in std_logic;cld_128hz:out std_logic);end;architecture one of fpq_128 isbeginprocess(clk_32mhz)Variable r: std_logic :=0;variable

16、 q: integer :=0;beginif clk_32mhzevent and clk_32mhz=1 thenif q=131071 then r:=not r;q:=0;else q:=q+1;end if;clk_128hz=r;End if;End process;End one;(FPQ512部分):Librara ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity fpq_512 isport(clk_32mhz:in std_logic;clk_512hz:out std_logic

17、);end;Architecture one of fpq_512 isbeginprocess(clk_32mhz)Variable r: std_logic :=0;Variable q: integer :=0;beginif clk_32mhzevent and clk_32mhz=1 thenif q=32767 then r:=not r;q:=0;else q:=q+1;end if;clk_512hz=r;End if;end process;end one;(FPQ1024部分):Library ieee;Use ieee.std_logic_1164.all;Use iee

18、e.std_logic_unsigned.all;Entity fpq_1024 isport(clk_32mhz:in std_logic;clk_1024hz:out std_logic);end;Architecture one of fpq_1024 isbeginprocess(clk_32mhz)variable r: std_logic :=0;variable q: integer :=0;beginif clk_32mhzevent and clk_32mhz=1 thenif q=16383 then r:=not r;q:=0;else q:=q+1;End if;clk

19、_1024hz=r;end if;end process;end one;6.2.3 计数器模块程序代码(1)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count isport(clk:in std_logic;en:in std_logic;clr:in std_logic;qa,qb,qc,qd:buffer std_logic_vector(3 downto 0);end;architecture art of count iscomponent cb10port(clk

20、,en,clr:in std_logic; count10:buffer std_logic_vector(3 downto 0);end component;signal clk2:std_logic;signal clk3:std_logic;signal clk4:std_logic;beginclk2=not qa(3);clk3=not qb(3);clk4=not qc(3);u1:cb10 port map(clk,en,clr,qa);u2:cb10 port map(clk2,en,clr,qb);u3:cb10 port map(clk3,en,clr,qc);u4:cb1

21、0 port map(clk4,en,clr,qd);end art;(2)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cb10 isport(clk,en,clr:in std_logic; count10:buffer std_logic_vector(3 downto 0);end cb10;architecture art of cb10 isbeginprocess(clk,clr,en)begin if clr=1 thencount10=0000;elsif ris

22、ing_edge(clk) thenif (en=1)thenif count10=1001 thencount10=0000;elsecount10=count10+1;end if;end if; end if;end process;end art;6.2.4 锁存器模块程序代码library ieee;use ieee.std_logic_1164.all;entity lock isport(lock:in std_logic; qa,qb,qc,qd:in std_logic_vector(3 downto 0); leda,ledb,ledc,ledd:out std_logic

23、_vector(7 downto 0);end;architecture art of lock issignal qal,qbl,qcl,qdl:std_logic_vector(3 downto 0);component bcd7port(bcd:in std_logic_vector(3 downto 0); led:out std_logic_vector(7 downto 0);end component;beginprocess(lock)beginif(lockevent and lock=1)thenqal=qa;qbl=qb;qcl=qc;qdl=qd;end if;end

24、process;u0:bcd7 port map(qal,leda);u1:bcd7 port map(qbl,ledb);u2:bcd7 port map(qcl,ledc);u3:bcd7 port map(qdl,ledd);end art;6.2.5 译码器模块程序代码library ieee;use ieee.std_logic_1164.all;entity bcd7 isport(bcd:in std_logic_vector(3 downto 0); led:out std_logic_vector(7 downto 0);end;architecture art of bcd

25、7 isbeginled=00111111 when bcd=0000 else00000110 when bcd=0001 else01011011 when bcd=0010 else01001111 when bcd=0011 else01100110 when bcd=0100 else01101101 when bcd=0101 else01111101 when bcd=0110 else00000111 when bcd=0111 else01111111 when bcd=1000 else01101111 when bcd=1001 else00000000;end art;

26、6.2.6 顶层文件程序代码library ieee;use ieee.std_logic_1164.all;entity pinlvji isport(clk:in std_logic; f_in:in std_logic; f_128,f_512,f_1024:out std_logic; ent,lockt,clrt:buffer std_logic; z1,z2,z3,z4:out std_logic_vector(7 downto 0);end pinlvji;architecture art of pinlvji issignal ens,locks,clrs,clk_temp:s

27、td_logic;signal qas,qbs,qcs,qds:std_logic_vector(3 downto 0);component ctrlport(clk:in std_logic; en,lock,clr:out std_logic);end component;component FPQPORT(CLK_32MHz:IN STD_LOGIC;CLK_1Hz:OUT STD_LOGIC);END component;component FPQ_128PORT(CLK_32MHz:IN STD_LOGIC;CLK_128Hz:OUT STD_LOGIC);END component

28、;component FPQ_512PORT(CLK_32MHz:IN STD_LOGIC;CLK_512Hz:OUT STD_LOGIC);END component;component FPQ_1024PORT(CLK_32MHz:IN STD_LOGIC;CLK_1024Hz:OUT STD_LOGIC);END component;component countport(clk,en,clr:in std_logic; qa,qb,qc,qd:out std_logic_vector(3 downto 0);end component;component lockport(lock:i

29、n std_logic; qa,qb,qc,qd:in std_logic_vector(3 downto 0);leda,ledb,ledc,ledd:out std_logic_vector(7 downto 0);end component;beginent=ens;lockt=locks;clrt=clrs;u0:ctrl port map(clk_temp,ens,locks,clrs);u1:FPQ port map(clk,clk_temp);u2:FPQ_128 port map(clk,f_128);u3:FPQ_512 port map(clk,f_512);u4:FPQ_

30、1024 port map(clk,f_1024);u5:count port map(f_in,ens,clrs,qas,qbs,qcs,qds);u6:lock port map(locks,qas,qbs,qcs,qds,z1,z2,z3,z4);end art;6.3 附录3 实物图实物如图6-2和图6-3所示:图6-2 实物图图6-3 实物图七、 答 谢最后要衷心的感谢王老师对我们耐心的指导,正由于他工作严谨、认真负责的态度和一丝不苟、循循善诱的工作作风,我们的设计才能顺利的完成。还要感谢学校的每一位老师,谢谢你们一直默默无闻的奉献,教会我们应该具备的基础知识,教会我们做人做事的道理。还要感谢同学们热情的帮助,谢谢你们一直的陪伴,帮助我完成这次毕业设计,真是辛苦你们了。希望我上交的成果能让你们感到欣慰。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

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


备案号:宁ICP备2025010119号-1

经营许可证:宁B2-20210002

宁公网安备 64010402000987号