VHDL实验四函数信号发生器设计._vhdl函数信号发生器

2020-02-28 其他范文 下载本文

VHDL实验四函数信号发生器设计.由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“vhdl函数信号发生器”。

VHDL实验四:函数信号发生器设计

设计要求:设计一个函数信号发生器,能产生方波,三角波,正弦波,阶梯波。设计概述:信号的输出实质上是指电压幅度随时间的变化。根据这个原理我们就可以设计函数信号发生器了。FPGA里面产生的数据只能是数字信号,最终我们通过连接8bit的DA转换器就能将数字信号转换成电压信号,从而实现了信号发生器的功能。

本设计有5个模块组成,其中有:方波发生器,三角波发生器,正弦波发生器,阶梯波发生器,4选1选择器。下面是我设计的整个过程: 方波发生器:实质上是一段时间输出0,一段时间输出255的数字信号,当然这有8位的通道输出。

程序设计如下:--工程名:方波发生器

--功能:产生方波,是通过交替送出全0和全1实现的,每32个时钟翻转一次--时间:2010-12-17 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity sqaure is port(clk,clr:in std_logic;

q:out integer range 0 to 255;end entity;architecture behav of sqaure is signal a:bit;begin proce(clk,clr--计数分频 variable cnt:integer range 0 to 32;begin if(clr='0' then a

end proce;proce(clk,a--信号输出 begin if clk'event and clk='1' then if a='1' then q

程序设计如下:--工程名:三角波信号发生器

--功能:产生的三角波以64个时钟为一个周期,输出q每次加减8。--时间:2010-12-17 library ieee;

use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity delta1 is port(clk:in std_logic;--时钟信号 rst:in std_logic;--复位信号

q:out std_logic_vector(7 downto 0;--输出信号 end entity;architecture behav of delta1 is begin variable tmp:std_logic_vector(7 downto 0;variable a:std_logic;begin if(rst='0' then tmp:=“00000000”;elsif clk'event and clk='1' then if(a='0' then if(tmp=“11111000” then--tmp=248 tmp:=“11111111”;

a:='1';--信号计数完成,下一次改成递减 else tmp:=tmp+8;--递增 end if;else if tmp=“00000111” then--tmp=7 tmp:=“00000000”;a:='0';--信号计数完成,下一次改成递增 else tmp:=tmp-8;--递减 end if;end if;end if;q

具体程序设计如下: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity sin1 is port(clk,clr:in std_logic;d:out integer range 0 to 255;end entity;architecture behav of sin1 is begin variable tmp:integer range 0 to 63;begin if clr='0' then d

tmp:=tmp+1;end if;case tmp is when 00=>dddddddddddddddddddddddddddddddddddddddddddddddd

when 48=>ddddddddddddddddnull;end case;end if;end proce;end behav;阶梯波发生器:实质上是一个直线递增的数字信号输出而已,和三角波发生没有什么差别。

--工程名:阶梯波信号发生器

--功能:改变该模块递增的常数,可以改变阶梯的个数--时间:2010-12-17 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;

use ieee.std_logic_arith.all;entity ladder1 is port(clk:in std_logic;--时钟信号 rst:in std_logic;--复位信号

q:out std_logic_vector(7 downto 0;--输出信号 end entity;architecture behav of ladder1 is begin proce(clk,rst variable tmp:std_logic_vector(7 downto 0;variable a:std_logic;begin if(rst='0' then--复位 tmp:=“00000000”;elsif clk'event and clk='1' then if a='0' then if tmp=“11111111” then tmp:=“00000000”;a:='1';

else tmp:=tmp+16;--以常数递增 a:='1';end if;else a:='0';end if;end if;q

最后我们要将模块进行整合,就需要设计一个选通模块,进行选择。

具体程序设计如下:--工程名:4 选 1 模块选择器--功能:选通模块作用--时间:2010-12-17 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity select4_1 is port(sel:in std_logic_vector(1 downto 0;--选择信号 d0,d1,d2,d3:in std_logic_vector(7 downto 0;--4 个信号发生器通道 q:out std_logic_vector(7 downto 0;--输出通道 end entity;architecture behav of select4_1 is begin proce(sel begin case sel is--选择 when“00”=> q q q q

位的数字信号转化成电压信号就能完成了整个 系统的设计了。总结:通过设计这个简单的数字信号发生器,我彻底的了解了如何设计一个函数 发生器。一直以来都想设计这个一个东西,所以今天终于完成了我一直以来的心 愿了。但是这仅仅是开始,要设计一个很好信号发生器,需要使用 DDS 的技术,因此希望我以后更加再接再厉,慢慢稳健的成长起来。

《VHDL实验四函数信号发生器设计..docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
VHDL实验四函数信号发生器设计.
点击下载文档
相关专题 vhdl函数信号发生器 设计 函数 信号发生器 vhdl函数信号发生器 设计 函数 信号发生器
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文