77范文网 - 专业文章范例文档资料分享平台

vhdl语言描述的4位十进制的频率计的设计

来源:网络收集 时间:2018-12-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

实验七 4位十进制频率计的设计

实验目的: 设计一个4位十进制频率计,学习复杂数字系统的设计方法。

实验原理:

根据频率的定义和频率测量的基本原理,测定信号的频率必须有一个脉宽为1秒的脉冲计数允许信号,1秒计数结束后,计数值(即所测信号频率)锁入锁存器,并为下一次测频作准备,即将计数器清零。 试验内容:

1、根据频率计的工作原理,将电路划分成控制器、计数器、锁存器和LED显示几个模块,

控制器——产生1秒脉宽的计数允许信号、锁存信号和计数器清零信号

计数器——对输入信号的脉冲数进行累计 锁存器——锁存测得的频率值

LED显示——将频率值显示在数码管上 顶层文件框图如下:

clkcontrollerrstDecimalcounterEnaOutputbuffera,b,c,d,e,f,g,dpLEDcontrollerS0~1

2、用元件例化语句写出频率计的顶层文件。

3、用VHDL硬件描述语言进行模块电路的设计。

本实验中不少模块在之前的实验中已经有所涉及,只需要对以前的设计做部分修改即可用于这次实验。

提示:十进制计数器输出的应是4位十进制数的BCD码,因此输出一共是4×4bit。

4、用QuartusII对设计进行编译、综合、仿真,给出仿真波形和时序分析数据(不包括数码管显示部分)。 5、通过QuartusII集成环境,将设计下载到实验电路上进行硬件测试。

实验结果:

各模块电路的VHDL描述: 10进制计数器 library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt10 is

port (rst,fx,ena:in std_logic; cout: out std_logic;

outy :out std_logic_vector(3 downto 0)); end cnt10;

architecture behv of cnt10 is begin

process (rst,ena,fx)

variable cqi :std_logic_vector(3 downto 0); begin

if rst='1' then cqi :=(others =>'0'); elsif fx'event and fx='1' then if ena ='1' then

if cqi < 9 then cqi:=cqi+1;cout<='0'; elsif cqi=9 then cqi :=(others =>'0'); cout<='1'; end if;

elsif ena='0' then cqi:=(others =>'0');

end if; end if;

outy <=cqi; end process; end behv;

4位10进计数器 library ieee;

use ieee.std_logic_1164.all; entity cnt10_4 is

port(fx,rst,ena:in std_logic; d:out std_logic_vector(15 downto 0)); end entity;

architecture one of cnt10_4 is component cnt10

port (rst,fx,ena:in std_logic; cout: out std_logic;

outy :out std_logic_vector(3 downto 0)); end component;

signal e:std_logic_vector(3 downto 0); begin u1:cnt10 map(fx=>fx,rst=>rst,ena=>ena,cout=>e(0),outy=>d(3 0));

u2:cnt10 map(fx=>e(0),rst=>rst,ena=>ena,cout=>e(1),outy=>d(7 4));

port downto port downto u3:cnt10 port map(fx=>e(1),rst=>rst,ena=>ena,cout=>e(2),outy=>d(11 downto 8));

u4:cnt10 port map(fx=>e(2),rst=>rst,ena=>ena,cout=>e(3),outy=>d(15 downto 12));

end architecture one;

16位锁存器 library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity latch4 is

port(d:in std_logic_vector(15 downto 0); ena,clk:in std_logic;

q:out std_logic_vector(15 downto 0)); end latch4;

architecture one of latch4 is begin

process(clk,ena,d)

variable cqi:std_logic_vector(15 downto 0); begin

if ena='0' then cqi:=cqi;

elsif clk'event and clk='1' then cqi:=d; end if; q<=cqi;

end process; end one;

LED控制模块 library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity led_controller is

port(d:in std_logic_vector(3 downto 0); a:out std_logic_vector(6 downto 0)); end led_controller;

architecture one of led_controller is begin process(d) begin case d is

when \when \when \when \when \when \when \when \when others=> null; end case; end process;

end;

控制模块 library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity control is

port (clk:in std_logic;

rst,ena: out std_logic); end control;

architecture behv of control is begin

process (clk)

variable cqi :std_logic_vector(2 downto 0); begin

if clk'event and clk='1' then

if cqi <1 then cqi:=cqi+1;ena<='1';rst<='0'; elsif cqi=1 then cqi :=(others =>'0'); ena<='0';rst<='1'; end if; end if;

end process; end behv;

总体例化语句:

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity cntf is

port(rset,clk:in std_logic; fx:in std_logic; ledout:out std_logic_vector(27 downto 0)); end entity;

architecture one of cntf is

component control

port (clk:in std_logic;

rst,ena: out std_logic); end component;

component cnt10_4

port(fx,rst,ena:in std_logic; d:out std_logic_vector(15 downto 0)); end component;

component latch4

port(d:in std_logic_vector(15 downto 0); ena,clk:in std_logic;

q:out std_logic_vector(15 downto 0)); end component;

component led_controller

port(d:in std_logic_vector(3 downto 0); a:out std_logic_vector(6 downto 0)); end component;

signal x,z:std_logic;

signal g,h:std_logic_vector(15 downto 0); signal leds:std_logic_vector(27 downto 0); begin

u1: control port map(clk=>clk,ena=>x,rst=>z); u2: cnt10_4 port map(fx=>fx,rst=>z,ena=>x,d=>g); u3: latch4 port map(clk=>clk,ena=>x,d=>g,q=>h);

u4: led_controller port map(d(3 downto 0)=>h(3 downto 0),a(6 downto 0)=>leds(6 downto 0));

u5: led_controller port map(d(3 downto 0)=>h(7 downto 4),a(6 downto 0)=>leds(13 downto 7));

u6: led_controller port map(d(3 downto 0)=>h(11 downto 8),a(6 downto 0)=>leds(20 downto 14));

u7: led_controller port map(d(3 downto 0)=>h(15 downto 12),a(6 downto 0)=>leds(27 downto 21)); ledout<=leds; end;

仿真波形:

输入CLK为1HZ脉冲,FX为10HZ时钟信号。根据程序设计,每七位对应一个数码管,从高到低排列即为(0111111)(0111111)(00001100)(0111111),数码管显示10进制数为0010,符合设计要求。 硬件测试结果及分析:

通过输入不同频率的信号,可通过面板上的四个七段数码管显示出结果。 四、思考题: 本实验中的控制器部分可以用以前实验中的哪个电路来实现,其输出的rst和ena信号是否可以合并为一个信号? 回答问题:

本实验中的控制部分可用实验四中的异步清零部分转换来。 RST与ENA可合并为一个信号。一个是控制计数器工作的信号,一个为清零信号,故可选择在计数时使用高电平,清规时使用低电平,因此可以和为一个。

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库vhdl语言描述的4位十进制的频率计的设计在线全文阅读。

vhdl语言描述的4位十进制的频率计的设计.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/345400.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: