实验四简单频率计的制作_第1页
实验四简单频率计的制作_第2页
实验四简单频率计的制作_第3页
实验四简单频率计的制作_第4页
实验四简单频率计的制作_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

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

文档简介

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 clk'event and clk='1' then if cnt<9 then cnt

4、:=cnt+1; else cnt:=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 do

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

6、存器锁存。计数器模块的程序:library ieee;use ieee.std_logic_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_v

7、ector(3 downto 0);variable x:std_logic;begin if sig'event 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"c

8、0:="0000" elsif door='1' then if c0<"1001" thenc0:=c0+1; elsec0:="0000"if c1<"1001" thenc1:=c1+1;else c1:="0000"if c2<"1001" thenc2:=c2+1;elsec2:="0000"if c3<"1001" thenc3:=c3+1;elsec3:="0000&quo

9、t;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&

10、lt;="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_arc;计数器电路图如图2.3所示:图3.3 计数器电路图3.4锁存器模块 在分频信号的下降沿到来时,锁存器将计数器的信号锁存,然

11、后送给编译模块中。锁存器模块的程序: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)

12、;beginif l'event and l='0' thent4:=a4;t3:=a3;t2:=a2;t1:=a1;t0:=a0;end if;q4<=t4;q3<=t3;q2<=t2;q1<=t1;q0<=t0;end process;end lock_arc;电路图如图2.4所示:图 3.4 锁存器电路图3.5译码信号模块 此模块是对四个锁存器进行选择,按顺序的将四个锁存器中的数值送给译码模块中译码。译码信号模块的程序:library ieee;use ieee.std_logic_1164.all;entity ch isport(

13、sel:in std_logic_vector(2 downto 0); a3,a2,a1,a0,dang:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0);end ch;architecture ch_arc of ch isbeginprocess(sel)begincase sel iswhen "000"=>q<=a0;when "001"=>q<=a1;when "010"=>q<=a2;when &qu

14、ot;011"=>q<=a3;when "111"=>q<=dang;when others=>q<="1111"end case;end process;end ch_arc;电路图如图2.5图3.5 译码信号电路图3.6片选模块 该模块接收到片选信号后,输出给显示器,选择显示那个显示管。片选模块的程序:library ieee;use ieee.std_logic_1164.all;entity ym isport(d:in std_logic_vector(2 downto 0); q:out std_

15、logic_vector(7 downto 0);end ym;architecture ym_arc of ym isbeginprocess(d)begincase d iswhen "000"=>q<="00000001"when "001"=>q<="00000010"when "010"=>q<="00000100"when "011"=>q<="00001000"when &q

16、uot;100"=>q<="00010000"when "101"=>q<="00100000"when "110"=>q<="01000000"when "111"=>q<="10000000"when others=>q<="00000000"end case;end process;end ym_arc;电路图如图2.6所示:图3.6 片选电路图3.7译码模块译

17、码模块的作用就是将译码信号模块中选择出的信号进行译码,并将其送给显示器。译码器模块的程序:library ieee;use ieee.std_logic_1164.all;entity disp isport(d:in std_logic_vector(3 downto 0); q:out std_logic_vector(6 downto 0);end disp;architecture disp_arc of disp isbeginprocess(d)begincase d iswhen "0000"=>q<="0111111"when

18、 "0001"=>q<="0000110"when "0010"=>q<="1011011"when "0011"=>q<="1001111"when "0100"=>q<="1100110"when "0101"=>q<="1101101"when "0110"=>q<="1111101"when "0111"=>q<="0100101"when "1000"=>q<="1111111"when "1001"=>q<="1101111"when others=>q<="0000000"end case;end process;end disp_arc;路图如图2.7所示:图3.7 译码电路图3.8 各个模块生成后,新建一个文件夹将每个模块生成

温馨提示

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

评论

0/150

提交评论