毕业设计(论文)-基于CPLD的数字频率计的设计.doc_第1页
毕业设计(论文)-基于CPLD的数字频率计的设计.doc_第2页
毕业设计(论文)-基于CPLD的数字频率计的设计.doc_第3页
毕业设计(论文)-基于CPLD的数字频率计的设计.doc_第4页
毕业设计(论文)-基于CPLD的数字频率计的设计.doc_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

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

文档简介

基于cpld的数字频率计的设计 摘 要 频率是电子技术中最基本的参数之一,与其他电参量的测量方案及结果关系非常密切。其中数字频率计在各方面领域都有很广泛的运用,随着科技的发展与生活的提高,数字频率计的需求也将大大提升。目前直接测频方法有两种:测频法和测周期法。测频法是在确定的时间tw内,记录被测信号的变化周期数nx,则测得的频率为:fx=nx/tw。测周期法需有标准信号频率fs,在待测信号的一个周期tx内,记录标准频率的周期数。则测得的频率为:fx=fs/ns 。本课题主要选择以cpld为核心器件,vhdl为编程语言,采用测频法设计一个简单实用的数字频率计,以计数器、译码器为核心,由内部分频输入信号、信息锁存、数字显示等功能模块组成,可以实现简单的频率测量。关键词 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, 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 record 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 subject 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 functional 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 时基控制模块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 设计背景转眼间大学的学习生涯即将结束,为了检验对这四年所学知识掌握运用的程度,针对电子信息专业课程的要求,培养出能利用所学理论知识与实践相结合,能独立思考,锻炼动手等方面的能力,基于个人爱好及所掌握的知识,本设计选择基于cpld的数字频率计的设计。1.1.2 设计目标(1)频率测量范围:19999hz。(2)输入被测信号幅度vi100mv。(3)测量1s时间内的脉冲数。(4)测量误差编译,提示没有错误后便可以仿真了。 2.新建波形文件,进入操作界面,先点击edict菜单,设置 end time ,一般情况大概设为10us,由于软件本身的缘故,end time值不应该设的太小,否则延时会很大,影响效果。3.7.2 硬件调试 软件仿真无误后,就可以与硬件相连。在这之前的先设置好管脚。点击“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方面的设计比较感兴趣,所以想通过此次毕业设计锻炼自己的动手能力,更好的把理论知识与实践联系起来,巩固、加深个人对电子设计方面的兴趣。设计过程中使用了 quartus ii软件。这个软件前几年已经学习使用过但还不是很熟练,通过老师与同学多次指导,经过多次反复操作最终基本掌握了它的使用方法。使我更加熟练掌握了编辑输入图形设计文件、编译设计文件、仿真设计文件及编程下载设计文件等各种不同的文件设计。因为各种原因,我们设计之前准备确实不是很充足,包括心理上还有自身能力上,所以自然的就造成了把时间花费在许多不必要的事情上,我建议以后学校能够在课堂外利用更多时间培训同学们相关的实践动手能力,让同学们提前有所准备,更加透彻学习与了解专业相关的知识与技能,相信同学们再次接触到设计之类时就不会忙手忙脚的了。总的来说通过这次毕业设计让我更加深刻的明白,理论上的知识与实际情况总是相差比较大的,做任何事情都不能想这是理所当然的,要通过自己亲身体会才能明白其中的奥秘。五、 参考文献1. 阎石主编,数字电子技术基础(第五版),高等教育出版社。3. 曹昕燕,周凤臣,聂春燕编著,eda技术实验与课程设计,清华大学出版社。4. 彭介华主编,电子技术课程设计指导,高等教育出版社。5. 张 原编著,可编程逻辑器件设计及应用,机械工业出版社。6. 荀殿栋,徐志军编著,数字电路设计实用手册,电子工业出版社。7. 潘松、黄继业编著,eda技术实用教程(第三版),科学出版社。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);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;use 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;else 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 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);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 ieee.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_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,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:cb10 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 rising_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_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 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 bcd7 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;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:std_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;component fpq_512port(clk_32mhz:in std_logic;clk_512hz:o

温馨提示

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

评论

0/150

提交评论