基于VHDL語言的波形發(fā)生器的設(shè)計(jì)_第1頁
基于VHDL語言的波形發(fā)生器的設(shè)計(jì)_第2頁
基于VHDL語言的波形發(fā)生器的設(shè)計(jì)_第3頁
基于VHDL語言的波形發(fā)生器的設(shè)計(jì)_第4頁
基于VHDL語言的波形發(fā)生器的設(shè)計(jì)_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、基于vhdl語言的波形發(fā)生器的設(shè)計(jì)基于vhdl語言的波形發(fā)生器的設(shè)計(jì)利用fpga芯片信號(hào)發(fā)生器的設(shè)計(jì)。當(dāng)按下開關(guān)1時(shí)產(chǎn)生三角波,當(dāng)按下開關(guān)2時(shí)產(chǎn)生正弦波,當(dāng)按下開關(guān)3時(shí)產(chǎn)生方波。本次設(shè)計(jì)采用xilinx公司的ise設(shè)計(jì)工具,在zedboard開發(fā)板中的xc7z020芯片上用vhdl來實(shí)現(xiàn),并且利用ise自帶的chipscop完成對(duì)fpga內(nèi)部的信號(hào)的讀取。這樣的設(shè)計(jì)具有體積小,修改升級(jí)容易等特點(diǎn)。本設(shè)計(jì)采用自頂向下、純文本實(shí)現(xiàn)數(shù)字時(shí)鐘的設(shè)計(jì)、下載和調(diào)試。1 設(shè)計(jì)原理本設(shè)計(jì)由信號(hào)產(chǎn)生,信號(hào)選擇,信號(hào)控制輸出三大模塊組合而成。其中信號(hào)產(chǎn)生模塊有:三角波模塊、方波模塊、正弦波模塊。本設(shè)計(jì)采用k0k2

2、這三個(gè)按鍵為信號(hào)選擇開關(guān),選擇信號(hào)產(chǎn)生模塊輸出的信號(hào)。(頂層設(shè)計(jì)的例化語句見附錄一)其rtl圖1-1: rtl圖1-12主要功能模塊u1:square方波產(chǎn)生模塊;u2:sin正弦波產(chǎn)生模塊;u3:delta三角波產(chǎn)生模塊;u4:sig_control數(shù)據(jù)選擇器模塊;u5,u6:為使用chipscope所需生成的ip核。2.1 u1方波產(chǎn)生模塊(程序見附錄二) 產(chǎn)生方波,初始化為幅值225的高電平,每有一次時(shí)鐘上升沿觸發(fā)產(chǎn)生一次計(jì)數(shù),當(dāng)計(jì)數(shù)值達(dá)到128時(shí)跳到為0的低電平。利用循環(huán)語句不斷的產(chǎn)生高低電平的方波輸出。原理如圖2-1:方波模塊rtl 圖2-12.2 u1正弦波產(chǎn)生模塊(程序見附錄三)

3、 功能是產(chǎn)生正弦波,產(chǎn)用信號(hào)抽樣的原理,在一個(gè)正弦信號(hào)中等間隔的抽樣64點(diǎn),此64點(diǎn)的幅值作為一個(gè)正弦波數(shù)據(jù)表,每有一次時(shí)鐘上升沿觸發(fā)便賦予輸出端q一個(gè)點(diǎn)的數(shù)據(jù),依次賦值64個(gè)點(diǎn)的數(shù)據(jù)便完成一個(gè)周期的正弦波的輸出。并利用循環(huán)語句不斷的產(chǎn)生正弦波的輸出。原理如圖2-2:正弦波模塊rtl 圖2-22.3 u1三角波產(chǎn)生模塊(程序見附錄四) 功能是產(chǎn)生三角波,初始化為幅值為0,每有一次時(shí)鐘上升沿觸發(fā)便進(jìn)行幅值加1,當(dāng)幅值達(dá)到最大255時(shí),每有一次時(shí)鐘上升沿觸發(fā)便進(jìn)行幅值減1,當(dāng)幅值減為0時(shí)完成一個(gè)周期的輸出。利用循環(huán)語句不斷的產(chǎn)生幅值為255的波形的輸出。原理圖如下:三角波模塊rtl 圖2-32.3

4、 u4數(shù)據(jù)選擇器模塊(見附錄五)利用數(shù)據(jù)選擇器模塊可以對(duì)三角波,正弦波,方波進(jìn)行三選一得輸出。當(dāng)開關(guān)d0撥通,d1,d2均閉合時(shí)q端輸出的是三角波;當(dāng)開關(guān)d1撥通,d0,d2均閉合時(shí)q端輸出的是方波;當(dāng)開關(guān)d2撥通,d0,d1均閉合時(shí)q端輸出的是正弦波;數(shù)據(jù)選擇器模塊rtl 圖2-43 硬件測(cè)試 當(dāng)程序下載到硬件之后,采用chipscope實(shí)現(xiàn)對(duì)fpga內(nèi)部信號(hào)的在線調(diào)試。在fpga已經(jīng)下載程序的情況下,添加我們關(guān)心的信號(hào)或者接口,將選定了端口chipscope(不妨理解為一個(gè)嵌入的系統(tǒng))加入到程序后重新布局布線下載到fpga中,此時(shí)我們就可以觀察信號(hào)和接口的值了。 在對(duì)ip核的設(shè)置中設(shè)置ch

5、ipscope每次對(duì)信號(hào)的抓取為2048個(gè)。3.1 對(duì)三角波的抓取 當(dāng)選擇信號(hào)k0置1,k1、k2置0時(shí),信號(hào)發(fā)生器輸出波形為三角波,如圖3-1-1所示: chipscope抓三角波波形 圖3-1-1利用chipscope的導(dǎo)出功能,得到具體的數(shù)據(jù)表。如圖3-1-2所示:chipscope對(duì)三角波形的導(dǎo)出 圖3-1-2 3.2 對(duì)方波的抓取當(dāng)選擇信號(hào)k1置1,k0、k2置0時(shí),信號(hào)發(fā)生器輸出波形為方波,如圖3-2-1所示:chipscope抓方波波形 圖3-2-1利用chipscope的導(dǎo)出功能,得到具體的數(shù)據(jù)表。如圖3-2-2所示:chipscope對(duì)方波形的導(dǎo)出 圖3-2-2 3.3 對(duì)正

6、弦波的抓取當(dāng)選擇信號(hào)k2置1,k0、k1置0時(shí),信號(hào)發(fā)生器輸出波形為正弦波,如圖3-3-1所示:chipscope抓正弦波形 圖3-3-1利用chipscope的導(dǎo)出功能,得到具體的數(shù)據(jù)表。如圖3-3-2所示:chipscope對(duì)正弦波形的導(dǎo)出 圖3-3-24 利用matlab實(shí)現(xiàn)直觀的觀測(cè)數(shù)據(jù)因?yàn)槔胏hipscope所導(dǎo)出的數(shù)據(jù)是一個(gè)一個(gè)的數(shù)組,所以無法對(duì)波形實(shí)現(xiàn)直觀的觀察。為了方便觀察實(shí)驗(yàn)數(shù)據(jù),利用matlab軟件實(shí)現(xiàn)對(duì)文本文件中的數(shù)據(jù)的讀。導(dǎo)出的每行數(shù)據(jù)可看做一個(gè)數(shù)組,每個(gè)數(shù)組第11位是波形的數(shù)據(jù)位,因此利用matlab只讀第11列的數(shù)據(jù)。利用matlab畫波形時(shí),橫軸作為波形的時(shí)間軸

7、,每間隔為1打一個(gè)點(diǎn),縱軸作為波形的幅值,用polt輸出將這些點(diǎn)鏈接起來,就可以直觀的觀測(cè)波形。方波的matlab程序如下:clc,cleardata=textread(f:ise designwave_generate實(shí)驗(yàn)數(shù)據(jù)delta.txt);%采集路徑th=data(:,11);%數(shù)組全部采集,采集第11位a=th;%轉(zhuǎn)置t=0:2047;%點(diǎn)的個(gè)數(shù)subplot(311)plot(t,a); 利用grid on,和subplot語句可以實(shí)現(xiàn)把三個(gè)波形畫在一起(matlab全部程序見附錄六),畫好后波形如圖4-1:matlab畫出波形 圖4-15有待改進(jìn) 程序中的頻率和幅值都是固定的,

8、未能實(shí)現(xiàn)頻率和幅值的可調(diào)節(jié),因此就沒有廣泛的實(shí)用性,進(jìn)一步的研究應(yīng)從波形發(fā)生器向信號(hào)發(fā)生器改變。附錄一頂層設(shè)計(jì)例化語句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方波產(chǎn)生模塊程序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 -上升沿觸發(fā) if tm

14、p=11111111 then tmp:=00000000; -計(jì)數(shù)為256時(shí)置零 else tmp:=tmp+1; end if; if tmp10000000 then f=1; - 當(dāng)計(jì)數(shù)小于128時(shí),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時(shí)q為255 else q=00000000; -f為0時(shí)q為0 end if; end if; end process;e

15、nd a;附錄三u2:sin正弦波產(chǎn)生模塊程序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; -對(duì)一個(gè)周期的正弦波采用64個(gè)點(diǎn)begin

16、if clrn=0 then qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnull; end case; end if; end if; end process; end a; 附錄四 u3:三角波產(chǎn)生模塊程序library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; -預(yù)先定義的操作符可以進(jìn)行重載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時(shí)跳到f1 if tmp=11111110 then tmp:=11111111; f:=1; else tmp:=tmp+

18、1; end if; else -三角波的下降,到0時(shí)跳到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:數(shù)據(jù)選擇器模塊程序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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論