实验四简单频率计的制作.

上传人:最**** 文档编号:116686234 上传时间:2019-11-17 格式:DOC 页数:13 大小:224.50KB
返回 下载 相关 举报
实验四简单频率计的制作._第1页
第1页 / 共13页
实验四简单频率计的制作._第2页
第2页 / 共13页
实验四简单频率计的制作._第3页
第3页 / 共13页
实验四简单频率计的制作._第4页
第4页 / 共13页
实验四简单频率计的制作._第5页
第5页 / 共13页
点击查看更多>>
资源描述

《实验四简单频率计的制作.》由会员分享,可在线阅读,更多相关《实验四简单频率计的制作.(13页珍藏版)》请在金锄头文库上搜索。

1、一 实验目的1熟悉Quarters-II软件的使用方法;2.了解VHDL语言编程;3.了解基本的自顶向下模块化设计思想;4.设计频率计并在软件上进行仿真;二设计的基本原理 2.1基本原理:数字频率计是用数字显示被测信号的频率的仪器,被测信号可以是正弦波,方波或者其他周期性变化的信号,它的基本原理是时基信号发生器提供标准的时基脉冲信号,若其周期为1s则门控电路的输出信号持续时间亦准确到1s。闸门电路有标准秒信号控制,当秒信号到来时闸门开通,信号通过闸门送到计数译码显示电路,秒信号结束时闸门关闭,计数器停止计数,由于计数器记得脉冲数N的是一秒内的累积数,所以被测频率是NHZ。闸门时间可以取大于或者

2、小于1秒的值,测得的频率时间间隔与闸门时间的取值成正比,在这里取的闸门时间为1s。数字频率计由分频器,片选电路,计数器,锁存器,译码电路和显示电路作为主要组成部分。三实验内容及步骤 在Quarters-II软件中采用文本编辑的方式(VHDL),生成如下各个模块的元器件。编译完成后点击file - creat/update - creat symbol files for current file .注意工程名与实体名要相同。3.1分频电路模块 分频器在总电路中有两个作用。由总图框图中分频器有两个输出,一个给计数器,一个给锁存器。时钟信号经过分频电路形成了20分频后的门信号。另一个给锁存器作锁存

3、信号,当信号为低电平时就锁存计数器中的数。分频模块的程序:library ieee;use ieee.std_logic_1164.all;entity fen isport(clk:in std_logic; q:out std_logic);end fen;architecture fen_arc of fen isbeginprocess(clk)variable cnt:integer range 0 to 9;variable x:std_logic;beginif clkevent and clk=1 then if cnt9 then cnt:=cnt+1; else cnt:=

4、0;x:=not x;end if; end if; q=x;end process;end fen_arc;分频电路图如图2.1 图3.1 分频电路图3.2片选信号电路模块 这个电路有两个用途:一是为后面的片选电路产生片选信号,二是为译码模块提供选择脉冲信号。片选信号模块的程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sel isport(clk:in std_logic; q:out std_logic_vector(2 downto 0);end sel;archite

5、cture sel_arc of sel isbeginprocess(clk)variable cnt:std_logic_vector(2 downto 0);beginif clkevent and clk=1 then cnt:=cnt+1;end if;q=cnt;end process;end sel_arc;电路图如图2.2图3.2 片选信号电路图3.3计数器模块 计数器模块为该电路中的核心模块,它的功能是:当门信号为上升沿时,电路开始计算半个周期内被测信号通过的周期数,到下升沿后结束。然后送给锁存器锁存。计数器模块的程序:library ieee;use ieee.std_lo

6、gic_1164.all;use ieee.std_logic_unsigned.all;entity corna isport(clr,sig,door:in std_logic; alm:out std_logic; q3,q2,q1,q0,dang:out std_logic_vector(3 downto 0);end corna;architecture corn_arc of corna isbeginprocess(door,sig)variable c3,c2,c1,c0:std_logic_vector(3 downto 0);variable x:std_logic;beg

7、in if sigevent and sig=1 then if clr=0 then alm=0;c3:=0000;c2:=0000;c1:=0000;c0:=0000; elsif door=0 then c3:=0000;c2:=0000;c1:=0000;c0:=0000; elsif door=1 then if c01001 thenc0:=c0+1; elsec0:=0000;if c11001 thenc1:=c1+1;else c1:=0000;if c21001 thenc2:=c2+1;elsec2:=0000;if c31001 thenc3:=c3+1;elsec3:

8、=0000;alm=1;end if; end if; end if; end if; end if;if c3/=0000 then q3=c3;q2=c2;q1=c1;q0=c0;dang=0100; elsif c2/=0000 then q3=0000;q2=c2;q1=c1;q0=c0;dang=0011; elsif c1/=0000 thenq3=0000;q2=0000;q1=c1;q0=c0;dang=0010; else q3=0000;q2=0000;q1=0000;q0=c0;dang=0001;end if; end if;end process; end corn_

9、arc;计数器电路图如图2.3所示:图3.3 计数器电路图3.4锁存器模块 在分频信号的下降沿到来时,锁存器将计数器的信号锁存,然后送给编译模块中。锁存器模块的程序:library ieee;use ieee.std_logic_1164.all;entity lock isport(l:in std_logic; a4,a3,a2,a1,a0:in std_logic_vector(3 downto 0); q4,q3,q2,q1,q0:out std_logic_vector(3 downto 0);end lock;architecture lock_arc of lock isbegin process(l) variable t4,t3,t2,t1,t0:std_logic_vector(3 downto 0);beginif levent and l=0 thent4:=a4;t3:=a3;t2:=a2;t1:=a1;t0:=a0;end if;q4=t4;q3=t3;q2=t2;q1=t1;q0qqqqqqqqqqqqqqq=0000

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号