CPLD实验报告(3)

2018-12-17 12:58

实验五 频率计设计

1.实验要求

利用VHDL语言设计一4位十进制频率计,要求能够准确地测量

所给频率,并利用FPGA实验箱进行实验。

2.实验目的

进一步熟悉VHDL语言的运用,并学会利用多个进程进行程序设

计,能够把以前的实验内容进行综合。

3.设计分析

按照设计要求进行分析,该频率计将有两个输入信号,分别为待测

信号xclk和时基信号clk,利用时基信号设计时间为1s的闸门信号。在闸门信号的作用下,4为计数器进行计时,当闸门信号结束时,把计数结果进行锁存并经过译码输出使数码管进行显示。本设计主要要设计出1s的闸门信号,4为计数器,锁存器、显示译码器以及让数码管进行动态显示。

4.程序设计

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity fqy_cnt is

port(clk:in std_logic; --clk为16HZ

xclk:in std_logic; -- 待测信号

wela: out std_logic_vector(2 downto 0); --we2,we1,we0 led: out std_logic_vector(7 downto 0));-- dp,g,f,e,d,c,b,a

end fqy_cnt;

architecture one of fqy_cnt is

signal count0: std_logic_vector(3 downto 0):=\个位 signal count1: std_logic_vector(3 downto 0):=\十位 signal count2: std_logic_vector(3 downto 0):=\百位 signal count3: std_logic_vector(3 downto 0):=\千位 signal div: std_logic_vector(3 downto 0):=\signal num: std_logic_vector(3 downto 0):=\signal discnt: std_logic_vector(1 downto 0):=\

signal lock0: std_logic_vector(3 downto 0):=\signal lock1: std_logic_vector(3 downto 0):=\signal lock2: std_logic_vector(3 downto 0):=\signal lock3: std_logic_vector(3 downto 0):=\signal clr,en,c0,c1,c2 : std_logic; begin

p1:process(clk)

variable cnt : integer range 0 to 7; variable x : std_logic; begin

if clk 'event and clk = '1' then

if cnt<7 then cnt:=cnt+1; else cnt:=0; x:=not x; end if; end if; en<=x;

end process p1; p2:process(clk) begin

if clk 'event and clk = '1' then

div<=div+'1'; if div=\

clr<='1'; else clr<='0';

end if; end if;

end process p2;

p3:process(xclk,clr,en) --个位计数器 begin

if clr = '1' then

count0<=\

elsif (xclk 'event and xclk = '1') and (en='1') then if count0=\

count0<=\

else

count0<=count0+'1'; c0<='1';

end if; end if;

end process p3;

p4:process(c0,clr,en) --十位计数器 begin

if clr = '1' then

count1<=\

elsif (c0 = '0') and (en='1') then if count1=\

count1<=\

else

count1<=count1+'1'; c1<='1';

end if; end if;

end process p4;

p5:process(c1,clr,en) --百位计数器 begin

if clr = '1' then

count2<=\

elsif (c1 = '0') and (en='1') then

if count2=\

count2<=\

else

count2<=count2+'1'; c2<='1';

end if; end if;

end process p5;

p6:process(c2,clr,en) --千位计数器 begin

if clr = '1' then

count3<=\

elsif (c2 = '0') and (en='1') then if count3=\

count3<=\

else

count3<=count3+'1';

end if; end if;

end process p6; p7:process(xclk) begin

if xclk 'event and xclk = '1' then

discnt<=discnt+'1'; end if;

end process p7; p8:process(discnt) begin

if discnt=\

wela<=\

elsif discnt=\

wela<=\

elsif discnt=\

wela<=\

elsif discnt=\

wela<=\

end if; end process p8; p9:process(num) begin case num is

when \when \when \when \when \when \when \when \when \when \when others =>led<=\end case; end process p9; p10:process(en) begin

if en='0' then lock0<=count0; lock1<=count1; lock2<=count2; lock3<=count3; end if;

end process p10; end one;

5.实验总结

本实验是一个简单的综合设计,其较好地体现了CPLD/FPGA的优

越性,一个频率计的设计避免了大量数字芯片的直接运用,而是由编程以及结合可编程逻辑器件去实现。本实验锻炼了我们运用VHDL语言的能力。


CPLD实验报告(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:精品小学教学楼施工组织设计方案2017年修订版

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: