基于VHDL语言的波形发生器的设计_第1页
基于VHDL语言的波形发生器的设计_第2页
基于VHDL语言的波形发生器的设计_第3页
基于VHDL语言的波形发生器的设计_第4页
基于VHDL语言的波形发生器的设计_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

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

文档简介

1、基于vhdl语言的波形发生器的设计基于vhdl语言的波形发生器的设计利用fpga芯片信号发生器的设计。当按下开关1时产生三角波,当按下开关2时产生正弦波,当按下开关3时产生方波。本次设计采用xilinx公司的ise设计工具,在zedboard开发板中的xc7z020芯片上用vhdl来实现,并且利用ise自带的chipscop完成对fpga内部的信号的读取。这样的设计具有体积小,修改升级容易等特点。本设计采用自顶向下、纯文本实现数字时钟的设计、下载和调试。1 设计原理本设计由信号产生,信号选择,信号控制输出三大模块组合而成。其中信号产生模块有:三角波模块、方波模块、正弦波模块。本设计采用k0k2

2、这三个按键为信号选择开关,选择信号产生模块输出的信号。(顶层设计的例化语句见附录一)其rtl图1-1: rtl图1-12主要功能模块u1:square方波产生模块;u2:sin正弦波产生模块;u3:delta三角波产生模块;u4:sig_control数据选择器模块;u5,u6:为使用chipscope所需生成的ip核。2.1 u1方波产生模块(程序见附录二) 产生方波,初始化为幅值225的高电平,每有一次时钟上升沿触发产生一次计数,当计数值达到128时跳到为0的低电平。利用循环语句不断的产生高低电平的方波输出。原理如图2-1:方波模块rtl 图2-12.2 u1正弦波产生模块(程序见附录三)

3、 功能是产生正弦波,产用信号抽样的原理,在一个正弦信号中等间隔的抽样64点,此64点的幅值作为一个正弦波数据表,每有一次时钟上升沿触发便赋予输出端q一个点的数据,依次赋值64个点的数据便完成一个周期的正弦波的输出。并利用循环语句不断的产生正弦波的输出。原理如图2-2:正弦波模块rtl 图2-22.3 u1三角波产生模块(程序见附录四) 功能是产生三角波,初始化为幅值为0,每有一次时钟上升沿触发便进行幅值加1,当幅值达到最大255时,每有一次时钟上升沿触发便进行幅值减1,当幅值减为0时完成一个周期的输出。利用循环语句不断的产生幅值为255的波形的输出。原理图如下:三角波模块rtl 图2-32.3

4、 u4数据选择器模块(见附录五)利用数据选择器模块可以对三角波,正弦波,方波进行三选一得输出。当开关d0拨通,d1,d2均闭合时q端输出的是三角波;当开关d1拨通,d0,d2均闭合时q端输出的是方波;当开关d2拨通,d0,d1均闭合时q端输出的是正弦波;数据选择器模块rtl 图2-43 硬件测试 当程序下载到硬件之后,采用chipscope实现对fpga内部信号的在线调试。在fpga已经下载程序的情况下,添加我们关心的信号或者接口,将选定了端口chipscope(不妨理解为一个嵌入的系统)加入到程序后重新布局布线下载到fpga中,此时我们就可以观察信号和接口的值了。 在对ip核的设置中设置ch

5、ipscope每次对信号的抓取为2048个。3.1 对三角波的抓取 当选择信号k0置1,k1、k2置0时,信号发生器输出波形为三角波,如图3-1-1所示: chipscope抓三角波波形 图3-1-1利用chipscope的导出功能,得到具体的数据表。如图3-1-2所示:chipscope对三角波形的导出 图3-1-2 3.2 对方波的抓取当选择信号k1置1,k0、k2置0时,信号发生器输出波形为方波,如图3-2-1所示:chipscope抓方波波形 图3-2-1利用chipscope的导出功能,得到具体的数据表。如图3-2-2所示:chipscope对方波形的导出 图3-2-2 3.3 对正

6、弦波的抓取当选择信号k2置1,k0、k1置0时,信号发生器输出波形为正弦波,如图3-3-1所示:chipscope抓正弦波形 图3-3-1利用chipscope的导出功能,得到具体的数据表。如图3-3-2所示:chipscope对正弦波形的导出 图3-3-24 利用matlab实现直观的观测数据因为利用chipscope所导出的数据是一个一个的数组,所以无法对波形实现直观的观察。为了方便观察实验数据,利用matlab软件实现对文本文件中的数据的读。导出的每行数据可看做一个数组,每个数组第11位是波形的数据位,因此利用matlab只读第11列的数据。利用matlab画波形时,横轴作为波形的时间轴

7、,每间隔为1打一个点,纵轴作为波形的幅值,用polt输出将这些点链接起来,就可以直观的观测波形。方波的matlab程序如下:clc,cleardata=textread(f:ise designwave_generate实验数据delta.txt);%采集路径th=data(:,11);%数组全部采集,采集第11位a=th;%转置t=0:2047;%点的个数subplot(311)plot(t,a); 利用grid on,和subplot语句可以实现把三个波形画在一起(matlab全部程序见附录六),画好后波形如图4-1:matlab画出波形 图4-15有待改进 程序中的频率和幅值都是固定的,

8、未能实现频率和幅值的可调节,因此就没有广泛的实用性,进一步的研究应从波形发生器向信号发生器改变。附录一顶层设计例化语句library ieee; use ieee.std_logic_1164.all; entity sig isport(clk,clrn : in std_logic; fb,sjb,zxb:in std_logic; ou:inout std_logic_vector(7 downto 0);end sig;architecture behavioral of sig iscomponent sinport ( clk,clrn : in std_logic; q : in

9、out std_logic_vector(7 downto 0);end component; component squareport ( clk,clrn : in std_logic; q : inout std_logic_vector(7 downto 0);end component; component deltaport ( clk,clrn : in std_logic; q : inout std_logic_vector(7 downto 0);end component; component sig_control port(delta,square,sin :in s

10、td_logic; d0,d1,d2 :in std_logic_vector(7 downto 0); q:out std_logic_vector(7 downto 0); end component; component ila port ( control : inout std_logic_vector(35 downto 0); clk : in std_logic; trig0 : in std_logic_vector(7 downto 0);end component;component icon port ( control0 : inout std_logic_vecto

11、r(35 downto 0);end component; signal control : std_logic_vector(35 downto 0);signal trig0 : std_logic_vector(7 downto 0);signal a:std_logic_vector(7 downto 0);signal b:std_logic_vector(7 downto 0);signal c:std_logic_vector(7 downto 0);beginu1: square port map(clk=clk ,clrn=clrn,q=a);u2: sin port map

12、(clk=clk ,clrn=clrn,q=b);u3: delta port map(clk=clk ,clrn=clrn,q=c);u4: sig_control port map(delta=sjb ,square=fb,sin=zxb,d0=a ,d1=b,d2=c,q=ou);u5: ila port map (control,clk,ou);u6: icon port map (control);end behavioral;附录二u1方波产生模块程序library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsi

13、gned.all;entity square is port(clk,clrn: in std_logic; q: out std_logic_vector(7 downto 0); end square; architecture a of square is signal f: std_logic;begin process(clk, clrn) variable tmp:std_logic_vector(7 downto 0); begin if clrn=0 then tmp:=00000000; else if clkevent and clk=1 then -上升沿触发 if tm

14、p=11111111 then tmp:=00000000; -计数为256时置零 else tmp:=tmp+1; end if; if tmp10000000 then f=1; - 当计数小于128时,f为1 else f=0; -否则f为0 end if; end if; end if; end process; process(clk,f) begin if clkevent and clk=1 then if f=1 then q=11111111; -f为1时q为255 else q=00000000; -f为0时q为0 end if; end if; end process;e

15、nd a;附录三u2:sin正弦波产生模块程序library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity sin is port (clk,clrn:in std_logic; q:inout std_logic_vector(7 downto 0); end sin; architecture a of sin is begin process(clk,clrn) variable tmp:integer range 63 downto 0; -对一个周期的正弦波采用64个点begin

16、if clrn=0 then qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnull; end case; end if; end if; end process; end a; 附录四 u3:三角波产生模块程序library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; -预先定义的操作符可以进行重载entity delta is port(clk,clrn:in std_logic; q:inout std_logic

17、_vector(7 downto 0);end delta; architecture a of delta is begin process(clk,clrn) variable tmp:std_logic_vector(7 downto 0); variable f:std_logic; begin if clrn=0 then tmp:=00000000; elsif clkevent and clk=1 then if f=0 then - 三角波的上升,到255时跳到f1 if tmp=11111110 then tmp:=11111111; f:=1; else tmp:=tmp+

18、1; end if; else -三角波的下降,到0时跳到f0 if tmp =00000001 then tmp:=00000000; f:=0; else tmp:=tmp-1; end if; end if; end if; q=tmp; end process;end a; 附录五 u4:数据选择器模块程序library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity sig_control is port( delta,square,sin :in std_logic; d0,d1,d2:in std_logic_vector(7 downto 0); q:out std_logic_vec

温馨提示

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

评论

0/150

提交评论