VHDL課程設(shè)計(jì)函數(shù)信號(hào)發(fā)生器_第1頁
VHDL課程設(shè)計(jì)函數(shù)信號(hào)發(fā)生器_第2頁
VHDL課程設(shè)計(jì)函數(shù)信號(hào)發(fā)生器_第3頁
VHDL課程設(shè)計(jì)函數(shù)信號(hào)發(fā)生器_第4頁
VHDL課程設(shè)計(jì)函數(shù)信號(hào)發(fā)生器_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、 學(xué)生姓名: 學(xué) 號(hào): 專 業(yè): 年級班級: 課程名稱: 可編程數(shù)字系統(tǒng)設(shè)計(jì) 實(shí)驗(yàn)項(xiàng)目: VHDL設(shè)計(jì)一信號(hào)發(fā)生器 試驗(yàn)時(shí)間: 2014年5月24日 指導(dǎo)老師: 一、實(shí)驗(yàn)?zāi)康模菏煜DA工具,掌握用VHDL語言進(jìn)行數(shù)字系統(tǒng)設(shè)計(jì)的基本方法和流程,提高工程實(shí)踐能力 二、設(shè)計(jì)任務(wù)設(shè)計(jì)信號(hào)發(fā)生器,用VHDL語言描述,用QuartusII工具編譯和綜合,并在實(shí)驗(yàn)板上調(diào)試并實(shí)現(xiàn)所要求功能和技術(shù)指標(biāo),撰寫實(shí)驗(yàn)報(bào)告,最后提交驗(yàn)收并答辯。題目一:設(shè)計(jì)正弦波發(fā)生器題目二:設(shè)計(jì)鋸齒波發(fā)生器題目三:設(shè)計(jì)三角波發(fā)生器三、功能要求與技術(shù)指標(biāo)基本功能: (1 )模擬輸出:由于FPGA上無D/A轉(zhuǎn)換模塊,因此設(shè)計(jì)中

2、必須包含PWM發(fā)生模塊,PWM輸出后經(jīng)過RC低通波電路轉(zhuǎn)換為電壓幅值正比于占空比的模擬電壓。濾波電路需自行設(shè)計(jì)。(2)可以通過按鍵設(shè)定波形的頻率,頻率可以顯示在數(shù)碼管上。(3)按鈕開關(guān)輸入須消抖處理。在完成以上功能的前提下,可增加其它一些實(shí)用的功能。要求:1、每個(gè)同學(xué)必須完成基本功能,在完成基本功能的前提下可自由發(fā)揮。2、實(shí)驗(yàn)報(bào)告主要內(nèi)容包含:設(shè)計(jì)原理、系統(tǒng)分析、程序設(shè)計(jì)、仿真/實(shí)驗(yàn)結(jié)果(例如波形圖和實(shí)驗(yàn)板運(yùn)行時(shí)的照片)、結(jié)論或分析、使用說明 等,在最后附上主要源程序。3、程序代碼結(jié)構(gòu)清晰,可讀性強(qiáng),關(guān)鍵語句應(yīng)注釋。四、設(shè)計(jì)原理:原理圖:原理圖(PS:RESTA按鍵已被刪除)cntpwm_ou

3、tpwmclkSMGDENCHTFILTRIGHTANMUA按鍵信號(hào)消抖模塊計(jì)數(shù)鍵模塊移復(fù)位鍵模塊選頻模塊數(shù)碼管模塊(動(dòng)態(tài)掃描)(頻率計(jì)算)PWM模塊(正弦波數(shù)據(jù)存儲(chǔ))(分頻比較)cnt信號(hào)發(fā)生器的原理框圖信號(hào)發(fā)生器的基本工作原理:1、利用ROM、數(shù)組或使用CASE語句將計(jì)算的正弦波采樣的占空比數(shù)據(jù)存儲(chǔ)。由分頻器將FPGA上的晶振進(jìn)行分頻所得的時(shí)鐘信號(hào)作為計(jì)數(shù)時(shí)鐘。最后進(jìn)行利用比較的方式得到占空比可調(diào)的脈沖波。同時(shí),分頻器的分頻系數(shù)可由鍵盤和數(shù)碼管配合的顯示數(shù)值進(jìn)行運(yùn)算反饋回PWM模塊,達(dá)到頻率可調(diào)的目的。此外,另設(shè)一輸出接至LED2,無法測量波形的情況下,利用呼吸燈的效果可檢測PWM模塊的完

4、成與頻率可調(diào)的成功性。2、鍵盤設(shè)移位復(fù)位鍵,數(shù)碼管計(jì)數(shù)鍵與頻率傳送鍵。同時(shí)設(shè)立消抖計(jì)數(shù)值,當(dāng)按鍵按下以后進(jìn)行計(jì)數(shù),在按鍵退出后,停止計(jì)數(shù),取最后一次計(jì)數(shù)作為按鍵信號(hào)完成按鍵消抖。按下移位復(fù)位鍵,數(shù)碼管位選下一位,同時(shí)示數(shù)復(fù)位清零,并且循環(huán)移位,當(dāng)按完4次按鍵后,數(shù)碼管全部清零。按下數(shù)碼管計(jì)數(shù)鍵,數(shù)碼管計(jì)數(shù),按一次計(jì)一次,采用十進(jìn)制循環(huán)計(jì)數(shù)。按下頻率傳送鍵,將數(shù)碼管所顯示的數(shù)值作為頻率傳送到PWM模塊,設(shè)頻率理論值范圍10hz99990hz。3、用于按鍵顯示的數(shù)碼管計(jì)數(shù)的計(jì)數(shù)采用十進(jìn)制。設(shè)定的計(jì)數(shù)值由四位數(shù)碼管動(dòng)態(tài)顯示,并且被設(shè)定的位選數(shù)碼管.點(diǎn)亮,表明該數(shù)碼管被選中。同時(shí)通電后,需利用移位復(fù)位

5、功能將數(shù)碼管清零。五、系統(tǒng)分析:1、根據(jù)原理圖與原理框圖: 系統(tǒng)電路可分成4個(gè)主干模塊:PWM模塊、按鍵消抖模塊、按鍵設(shè)定模塊、數(shù)碼管模塊。 PWM:通過對正弦波采樣存儲(chǔ)并利用時(shí)鐘分頻再進(jìn)行比較獲得PWM波,同時(shí)分頻系數(shù)由按鍵與數(shù)碼管陪和共同反饋運(yùn)算結(jié)果進(jìn)行分頻。按鍵消抖:按鍵按下是會(huì)產(chǎn)生不穩(wěn)定,設(shè)定何時(shí)的計(jì)數(shù)時(shí)間,再取按鍵拔起后獲得的最后一次計(jì)數(shù)作為按鍵信號(hào)。 按鍵設(shè)定:按鍵計(jì)數(shù),按下后數(shù)碼管進(jìn)行計(jì)數(shù)。移位復(fù)位,按下后數(shù)碼管位選再移位與復(fù)位下一位數(shù)碼管。頻率傳送,將數(shù)碼管示數(shù)作為頻率傳送到PWM模塊。數(shù)碼管:動(dòng)態(tài)掃描,頻率值顯示在數(shù)碼管上 。2、說明:數(shù)碼管顯示不穩(wěn)定,使用前先用移位復(fù)位鍵將

6、示數(shù)清零。測六、程序設(shè)計(jì):LIBRARY IEEE;USE IEEE. STD_LOGIC_1164.ALL;USE IEEE. STD_LOGIC_UNSIGNED.ALL;USE IEEE.NUMERIC_STD.ALL;ENTITY zxb_mao ISPORT(CLK :IN STD_LOGIC;RIGHTA:IN STD_LOGIC;-右移輸入鍵CNTFILT:IN STD_LOGIC;-頻率選擇鍵RESTA :IN STD_LOGIC;-復(fù)位輸入鍵NUMA:IN STD_LOGIC;-按鍵計(jì)數(shù)輸入鍵PWM:OUT STD_LOGIC;PWM_LED :OUT STD_LOGIC;-

7、LED亮燈SMG:OUT STD_LOGIC_VECTOR (7 DOWNTO 0); -數(shù)碼管的段數(shù)據(jù)DEN:OUT STD_LOGIC_VECTOR (3 DOWNTO 0); -數(shù)碼管的選通信號(hào) END zxb_mao;ARCHITECTURE syn OF zxb_mao ISsignal a,b,c,d:integer range 0 to 9;-輸入數(shù)signal cnt:integer range 0 to 50000000;-調(diào)頻頻信號(hào)signal num :integer range 0 to 9; -數(shù)碼管顯示計(jì)數(shù)signal num_1 :integer range 0

8、to 3;-數(shù)碼管位移數(shù)signal count:integer range 0 to 50000000;-晶振分頻計(jì)數(shù)signal count_key:integer range 0 to 2499;-鍵盤掃描分頻signal clkcnt:std_logic;-可調(diào)分頻時(shí)鐘signal cout1:integer range 0 to 255;signal COM:integer range 0 to 255;-采樣數(shù)據(jù)signal tmp:std_logic_vector(5 downto 0);signal key1filt : std_logic;-按鍵NUMA消抖后得到的信號(hào)sig

9、nal key1cnt: integer range 0 to 50000000; -用于對NUMA按鍵輸入有效時(shí)間進(jìn)行計(jì)數(shù)signal key2filt : std_logic;-按鍵RIGHTA消抖后得到的信號(hào)signal key2cnt: Integer range 0 to 50000000; -用于對RIGHT_按鍵輸入有效時(shí)間進(jìn)行計(jì)數(shù)signal key3filt : std_logic;-按鍵CNTFILT消抖后得到的信號(hào)signal key3cnt: integer range 0 to 50000000; -用于對LIFT_按鍵輸入有效時(shí)間進(jìn)行計(jì)數(shù)signal count1:

10、integer range 0 to 500000000;signal cout2:std_logic_vector(3 downto 0);signal clk1hz:std_logic;signal clk100khz:std_logic;BEGIN- -PWM模塊 PROCESS(CLK)variable tmp :integer; -時(shí)鐘分頻實(shí)現(xiàn)頻率可調(diào) BEGIN tmp:=tmp; IF rISing_edge(CLK) THEN IF count=cnt then count<=0; CLKCNT<='1'ELSE count<=count+1;

11、 CLKCNT<='0' END IF; END IF;END PROCESS;PROCESS(CLKCNT) BEGIN IF rISing_edge(CLKCNT) THEN IF cout1=255 THEN cout1<=0; tmp<=tmp+1; IF tmp="111111" then tmp<="000000" END IF; ELSE cout1<=cout1+1; END IF; END IF; END PROCESS;process(tmp) -正弦波數(shù)據(jù)采樣存儲(chǔ) begin case

12、conv_integer(tmp) is when 00=>COM<=255; when 01=>COM<=254; when 02=>COM<=252; when 03=>COM<=249; when 04=>COM<=245; when 05=>COM<=239; when 06=>COM<=233; when 07=>COM<=225; when 08=>COM<=217; when 09=>COM<=207; when 10=>COM<=197; when

13、 11=>COM<=186; when 12=>COM<=174; when 13=>COM<=162; when 14=>COM<=150; when 15=>COM<=137; when 16=>COM<=124; when 17=>COM<=112; when 18=>COM<=99; when 19=>COM<=87; when 20=>COM<=75; when 21=>COM<=64; when 22=>COM<=53; when 23=&

14、gt;COM<=43; when 24=>COM<=34; when 25=>COM<=26; when 26=>COM<=19; when 27=>COM<=13; when 28=>COM<=8; when 29=>COM<=4; when 30=>COM<=1; when 31=>COM<=0; when 63=>COM<=255; when 62=>COM<=254; when 61=>COM<=252; when 60=>COM<=24

15、9; when 59=>COM<=245; when 58=>COM<=239; when 57=>COM<=233; when 56=>COM<=225; when 55=>COM<=217; when 54=>COM<=207; when 53=>COM<=197; when 52=>COM<=186; when 51=>COM<=174; when 50=>COM<=162; when 49=>COM<=150; when 48=>COM<=13

16、7; when 47=>COM<=124; when 46=>COM<=112; when 45=>COM<= 99; when 44=>COM<=87; when 43=>COM<=75; when 42=>COM<=64; when 41=>COM<= 53; when 40=>COM<=43; when 39=>COM<=34; when 38=>COM<=26; when 37=>COM<= 19; when 36=>COM<=13; when

17、 35=>COM<=8; when 34=>COM<=4; when 33=>COM<= 1; when 32=>COM<=0;when others=>null; end case;END PROCESS;PROCESS(CLK) BEGIN IF rISing_edge(CLK) THEN IF cout1 > COM THEN -比較計(jì)數(shù)采樣PWM PWM <='0' PWM_LED <='0'-LED實(shí)現(xiàn)PWM檢測 ELSE PWM <='1' PWM_LED

18、<='1'-LED實(shí)現(xiàn)PWM檢測 END IF; END IF; END PROCESS;- -按鍵消抖模塊PROCESS (NUMA)-NUMA按鍵消抖 constant N :integer := 5000000;-消抖時(shí)間,對于50Mhz的基準(zhǔn)時(shí)鐘,這相當(dāng)于0.1SBEGIN IF CLK'event and CLK = '1' THENIF NUMA = '0' THEN -當(dāng)key1 輸入低電平,即按鍵按下IF key1cnt /= N THEN -一直計(jì)數(shù)到Nkey1cnt <= key1cnt + 1;END I

19、F;IF key1cnt = N-1 THEN -最后一個(gè)計(jì)數(shù)時(shí)輸出key1filt脈沖 key1filt <= '1'ELSEkey1filt <= '0'END IF;ELSE -若key1 輸入高電平,表明按鍵被釋放key1cnt <= 0;END IF;END IF;END PROCESS;PROCESS (RIGHTA)-RIGHTA按鍵消抖 constant N :integer := 5000000;BEGIN IF CLK'event and CLK = '1' THENIF RIGHTA= '0

20、' THEN IF key2cnt /= N THEN key2cnt <= key2cnt + 1;END IF;IF key2cnt = N-1 THEN key2filt <= '1'ELSEkey2filt <= '0'END IF;ELSE key2cnt <= 0;END IF;END IF;END PROCESS;PROCESS (CNTFILT)-CNTFILT按鍵消抖 constant N :integer := 5000000;BEGIN IF CLK'event and CLK = '1

21、9; THENIF CNTFILT = '0' THEN IF key3cnt /= N THEN key3cnt <= key3cnt + 1;END IF;IF key3cnt = N-1 THEN key3filt <= '1'ELSEkey3filt <= '0'END IF;ELSE key3cnt <= 0;END IF;END IF;END PROCESS;-四進(jìn)制計(jì)數(shù)移動(dòng)模塊RIGHTAPROCESS (key2filt)BEGINIF (key2filt='1') THEN -按鍵RIGH

22、TA經(jīng)消抖處理后IF num_1 = 3 THEN num_1 <= 0;ELSEnum_1 <= num_1 + 1;END IF;END IF;END PROCESS;-十進(jìn)制計(jì)數(shù)模塊NUMA,RIGHT_,LIFT_PROCESS(CLK) BEGIN IF rISing_edge(CLK) THEN IF count_key=249 THEN count_key<=0; clk100khz<='1' ELSE count_key<=count_key+1; clk100khz<='0' END IF; END IF;E

23、ND PROCESS;PROCESS (clk100khz,key1filt,key2filt)BEGINIF CLK'event and CLK = '1' THENIF key2filt='1'THEN-復(fù)位與移位復(fù)位num <= 0 after 50ns;ELSE IF (key1filt = '1') THEN -按鍵NUMA 經(jīng)消抖處理后IF num = 9 THEN num <= 0;ELSEnum <= num + 1;END IF;END IF;END IF;END IF;END PROCESS;- -輸

24、入寄存模塊PROCESS(num,num_1) BEGINCASE num_1 ISWHEN 0 => a <= num; WHEN 1 => b <= num; WHEN 2 => c <= num; WHEN 3 => d <= num; WHEN others =>NULL; END CASE;END PROCESS;- -按鍵選定頻率模塊PROCESS(key3filt) BEGINIF key3filt='1'THEN cnt <= 50000000/(a*1000+1)+(b*100+1)+(c*10+1)

25、+(d*1+1)*256*64); -實(shí)現(xiàn)頻率可調(diào)END IF;END PROCESS;- -數(shù)碼管動(dòng)態(tài)掃描頻率及顯示模塊PROCESS(CLK) BEGIN IF rISing_edge(CLK) THEN IF count1=24999 THEN count1<=0; clk1hz<='1' ELSE count1<=count1+1; clk1hz<='0' END IF; END IF; END PROCESS; PROCESS(clk1hz) BEGIN IF rISing_edge(clk1hz) THEN IF cout2=

26、"1000" THEN cout2<="0000" ELSE cout2<=cout2+1; END IF; END IF; END PROCESS; PROCESS(clk1hz) BEGIN IF cout2="0000" THEN DEN<="0111"CASE a ISWHEN 0 => SMG <= "11000000" - 0WHEN 1 => SMG <= "11111001" - 1WHEN 2 => SMG &

27、lt;= "10100100" - 2WHEN 3 => SMG <= "10110000" - 3WHEN 4 => SMG <= "10011001" - 4WHEN 5 => SMG <= "10010010" - 5 WHEN 6 => SMG <= "10000010" - 6WHEN 7 => SMG <= "11111000" - 7WHEN 8 => SMG <= "100000

28、00" - 8WHEN 9 => SMG <= "10010000" - 9WHEN others =>NULL; END CASE; END IF; IF num_1=0 and cout2="0001" THEN SMG<="01111111" DEN<="0111"END IF; IF cout2="0010" THEN DEN<="1011"CASE b ISWHEN 0 => SMG <= "110

29、00000" - 0WHEN 1 => SMG <= "11111001" - 1WHEN 2 => SMG <= "10100100" - 2WHEN 3 => SMG <= "10110000" - 3WHEN 4 => SMG <= "10011001" - 4WHEN 5 => SMG <= "10010010" - 5 WHEN 6 => SMG <= "10000010" - 6WH

30、EN 7 => SMG <= "11111000" - 7WHEN 8 => SMG <= "10000000" - 8WHEN 9 => SMG <= "10010000" - 9WHEN others =>NULL; END CASE; END IF; IF num_1=1 and cout2="0011" THEN SMG<="01111111" DEN<="1011" END IF; IF cout2="

31、0100" THEN DEN<="1101"CASE c ISWHEN 0 => SMG <= "11000000" - 0WHEN 1 => SMG <= "11111001" - 1WHEN 2 => SMG <= "10100100" - 2WHEN 3 => SMG <= "10110000" - 3WHEN 4 => SMG <= "10011001" - 4WHEN 5 => SMG

32、 <= "10010010" - 5WHEN 6 => SMG <= "10000010" - 6WHEN 7 => SMG <= "11111000" - 7WHEN 8 => SMG <= "10000000" - 8WHEN 9 => SMG <= "10010000" - 9WHEN others =>NULL;END CASE;END IF;IF num_1=2 and cout2="0101" THENS

33、MG<="01111111"DEN<="1101"END IF;IF cout2="0110" THEN DEN<="1110"CASE d ISWHEN 0 => SMG <= "11000000" - 0WHEN 1 => SMG <= "11111001" - 1WHEN 2 => SMG <= "10100100" - 2WHEN 3 => SMG <= "10110000" - 3WHEN 4 => SMG <= "10011001" - 4WHEN 5 => SMG <= "10010010" - 5WHEN 6 => SMG

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論