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

下載本文檔

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

文檔簡介

1、數(shù)字電路課程設(shè)計(jì)報(bào)告目錄第一部分:要求41.1 技術(shù)要求41.2 功能要求41.3 本人任務(wù)4 第二部分 設(shè)計(jì)5 2.1 軟件電路方案設(shè)計(jì)5 2.2 原理框圖5 第三部分 單元模塊設(shè)計(jì),仿真結(jié)果及分析53.1 分頻器模塊53.2 頻率選擇63.3 幅度選擇73.4 六種波形設(shè)計(jì)83.5 輸出模塊19第四部分 頂層模塊214.1 頂層模塊設(shè)計(jì)214.2 仿真結(jié)果及分析19第五部分 硬件電路設(shè)計(jì)及安裝圖215.1 連線圖245.2 輸入、輸出信號說明245.3 設(shè)計(jì)中需要注意的問題25第六部分 調(diào)試結(jié)果說明及分析266.1 實(shí)體圖266.2 輸出實(shí)物波形266.3 設(shè)計(jì)中需要注意的問題32第七部分

2、 收獲體會30第一部分:要求1.1 技術(shù)要求1)生成方波、三角波、正弦波;2)可以進(jìn)行簡單的頻率選擇或相幅調(diào)節(jié);3)在完成前三種波形的情況下可以進(jìn)行波形類別的擴(kuò)展;4)用VHDL語言設(shè)計(jì)符合上述功能要求的函數(shù)發(fā)生器,并用層次化設(shè)計(jì)方法設(shè)計(jì)該電路; 5)對各個(gè)模塊的功能進(jìn)行仿真,并掌握數(shù)字信號發(fā)生器電路的設(shè)計(jì)及其調(diào)試方法。1.2 功能要求 實(shí)現(xiàn)基于FPGA的簡易多功能信號發(fā)生器,產(chǎn)生穩(wěn)定的方波、三角波、正弦波、鋸齒波、階梯波、梯形波輸出,并用數(shù)碼管輸出相應(yīng)數(shù)字,且頻率、幅值可調(diào)。具體要求如下:通過撥動開關(guān)S3、S2、S1實(shí)現(xiàn)波形的選擇:共六種,同時(shí)數(shù)碼管顯示“1”到“6”;通過撥動開關(guān)A2、A1

3、實(shí)現(xiàn)波形幅度的選擇:共計(jì)四種;通過撥動開關(guān)F2、F1實(shí)現(xiàn)波形頻率的選擇:共計(jì)四種;下載并測試電路的功能,用示波器觀察DAC0832輸出波形。1.3 本人任務(wù) 進(jìn)行基于vhdl的軟件設(shè)計(jì),包括頂層模塊設(shè)計(jì),配合硬件進(jìn)行硬件仿真和測試。 第二部分 設(shè)計(jì) 2.1 軟件電路方案設(shè)計(jì) 對六個(gè)波形模塊和三個(gè)選擇模塊進(jìn)行單獨(dú)編寫,最后設(shè)計(jì)頂層模塊輸出。在確定課題的第一天,我和我的組員查找資料,初步確定了電路的設(shè)計(jì)方案。2.2 原理框圖 信號輸出波形選擇芯片(信號選擇)頻率選擇幅度選擇芯片(信號選擇) 輸出模塊第三部分 單元模塊設(shè)計(jì),仿真結(jié)果及分析3.1 分頻器模塊實(shí)體框圖程序清單:library ieee;

4、use ieee.std_logic_1164.all;entity fana is port(a:in integer RANGE 0 TO 312; -a為頻率輸入的初始值 clk:in std_logic; q:out std_logic); -q為輸出的脈沖頻率end;architecture fana_arc of fana isbegin process(clk) variable b,d:std_logic; variable c:integer RANGE 0 TO 312; begin if clk'event and clk='1' then if

5、b='0' then -檢測b c:=a-1; -b為低電平則將a-1送到c b:='1' -且令b=1 else if c=1 then -b為1時(shí)檢測c b:='0' -c=1時(shí)使b=0 d:=not d; -d取反 else c:=c-1; -c不等于1時(shí)c-1 end if; end if; end if; q<=d; -將d作為頻率輸出 end process;end;分析:這一部分主要實(shí)現(xiàn)對fpga內(nèi)部時(shí)鐘的初始分頻。波形如上,當(dāng)輸入a為256時(shí),每256個(gè)clk脈沖后q發(fā)生一個(gè)脈沖。3.2 頻率選擇 實(shí)體框圖 程序清單:lib

6、rary ieee;use ieee.std_logic_1164.all;entity chuzhi is port(f0:in std_logic_vector(1 downto 0); -f0初始頻率選擇開關(guān) q:out integer RANGE 0 TO 312);end;architecture chu_arc of chuzhi isbegin with f0 select -四種不同的初值 q<=312 when"00", 201 when"01", 101 when"10", 10 when"11&q

7、uot;, NULL when others;end;分析:這部分程序?qū)崿F(xiàn)脈沖頻率的選擇,當(dāng)f0為00、01、10、11時(shí),頻率分別為312、201、101、10;將此輸出作為分頻器的輸入。3.3 幅度選擇實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;entity fudu is port(f1:in std_logic_vector(1 downto 0); -f0初始頻率選擇開關(guān) q:out integer RANGE 0 TO 255);end;architecture fudu_arc of fudu isbegin with f1

8、 select -四種不同的初值 q<=255 when"00", 207 when"01", 167 when"10", 119 when"11", NULL when others;end; 分析:此程序?yàn)榉冗x擇,當(dāng)f1為00、01、10、11時(shí),幅度分別為255、207、167、169。3.4 六種波形設(shè)計(jì)a、 方波 實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;entity square isport(clk,clr:in std_logic;

9、k:in integer range 0 to 255; -幅度選擇信號 q:out integer range 0 to 255); -方波輸出end;architecture sq_arc of square issignal a:bit;begin process(clr,clk) variable cnt:integer; begin if clr='0' then a<='0' elsif clk'event and clk='1' then -時(shí)鐘上升沿 if cnt<31 then cnt:=cnt+1; -cn

10、t未到31時(shí)加1 else cnt:=0; -cnt到31時(shí)清零 a<=not a; -并將a取反 end if; end if; end process;process(clk,a) begin if clk'event and clk='1' then if a='1' then -每個(gè)時(shí)鐘上升沿檢測a q<=k; -a為1則q為最大值,即高電平else q<=0; -a為0時(shí)取反,q為最小值end if; end if; end process;end;分析:64個(gè)上升沿脈沖形成一個(gè)周期,半個(gè)周期為高電平255,半個(gè)周期低電平0。

11、b、三角波實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity delta is port(clk,clr:in std_logic; k:in integer range 0 to 255; -k幅度選擇信號 q:out integer range 0 to 255);end delta;architecture a of delta isbegin process(clk,clr) variable num:integer range 0 to 255; variab

12、le ff:std_logic;-上升沿/下降沿判斷標(biāo)志,為0時(shí)上升,為1時(shí)下降 begin if clr='0' then -異步復(fù)位端 num:=0; elsif clk'event and clk='1' then -上升沿 if ff='0' then if num=k-7 then num:=k; ff:='1' else num:=num+8; -ff=0,每個(gè)上升沿脈沖加8 end if; else if num=7 then num:=0; ff:='0' else num:=num-8;

13、-ff=1,下降沿,每個(gè)脈沖減8 end if; end if; end if; q<=num; end process;end a;分析:每個(gè)脈沖上升8個(gè)點(diǎn),點(diǎn)連成線形成三角的上升和下降曲線。由上圖可知當(dāng)幅度輸入為207時(shí),當(dāng)上升到207個(gè)點(diǎn)時(shí)下降。c、正弦波實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sin is port(clk,clr:in std_logic; k:in integer range 0 to 255; -幅度選擇信號 d:out

14、integer range 0 to 255);end;architecture sin_arc of sin isbegin process(clk,clr,k) variable tmp:integer range 0 to 63; begin if clr='0' then d<=0; elsif clk'event and clk='1' then -時(shí)鐘上升沿 if tmp=63 then -tmp=63則清零 tmp:=0; else tmp:=tmp+1; -否則tmp+1 end if; if k=255 then case tmp

15、 is when 00=>d<=255; when 01=>d<=254; when 02=>d<=252; -上升曲線 when 03=>d<=249; when 04=>d<=245; when 05=>d<=239; when 06=>d<=233; when 07=>d<=225; when 08=>d<=217; when 09=>d<=207; when 10=>d<=197; when 11=>d<=186; when 12=>d&

16、lt;=174; when 13=>d<=162; when 14=>d<=150; when 15=>d<=137; when 16=>d<=124; when 17=>d<=112; when 18=>d<=99; when 19=>d<=87; when 20=>d<=75; when 21=>d<=64; when 22=>d<=53; when 23=>d<=43; when 24=>d<=34; when 25=>d<=26;

17、when 26=>d<=19; when 27=>d<=13; when 28=>d<=8; when 29=>d<=4; when 30=>d<=1; when 31=>d<=0; when 32=>d<=0; -下降曲線 when 33=>d<=1; when 34=>d<=4; when 35=>d<=8; when 36=>d<=13; when 37=>d<=19; when 38=>d<=26; when 39=>d<

18、;=34; when 40=>d<=43; when 41=>d<=53; when 42=>d<=64; when 43=>d<=75; when 44=>d<=87; when 45=>d<=99; when 46=>d<=112; when 47=>d<=124; when 48=>d<=137; when 49=>d<=150; when 50=>d<=162; when 51=>d<=174; when 52=>d<=186; w

19、hen 53=>d<=197; when 54=>d<=207; when 55=>d<=217; when 56=>d<=225; when 57=>d<=233; when 58=>d<=239; when 59=>d<=245; when 60=>d<=249; when 61=>d<=252; when 62=>d<=254; when 63=>d<=255; -完成一個(gè)周期 when others=>NULL; end case; elsif k=

20、207 then case tmp is when 00=>d<=207; when 01=>d<=206; when 02=>d<=205; -上升曲線 when 03=>d<=202; when 04=>d<=199; when 05=>d<=195; when 06=>d<=190; when 07=>d<=183; when 08=>d<=177; when 09=>d<=169; when 10=>d<=160; when 11=>d<=15

21、2; when 12=>d<=142; when 13=>d<=132; when 14=>d<=123; when 15=>d<=111; when 16=>d<=100; when 17=>d<=91; when 18=>d<=80; when 19=>d<=70; when 20=>d<=61; when 21=>d<=52; when 22=>d<=43; when 23=>d<=35; when 24=>d<=28; when 2

22、5=>d<=21; when 26=>d<=15; when 27=>d<=10; when 28=>d<=6; when 29=>d<=3; when 30=>d<=1; when 31=>d<=0; when 32=>d<=0; -下降曲線 when 33=>d<=1; when 34=>d<=3; when 35=>d<=6; when 36=>d<=10; when 37=>d<=15; when 38=>d<=21;

23、when 39=>d<=28; when 40=>d<=35; when 41=>d<=43; when 42=>d<=52; when 43=>d<=61; when 44=>d<=70; when 45=>d<=80; when 46=>d<=91; when 47=>d<=100; when 48=>d<=111; when 49=>d<=123; when 50=>d<=132; when 51=>d<=142; when 52=&

24、gt;d<=152; when 53=>d<=160; when 54=>d<=169; when 55=>d<=177; when 56=>d<=183; when 57=>d<=190; when 58=>d<=195; when 59=>d<=199; when 60=>d<=202; when 61=>d<=205; when 62=>d<=206; when 63=>d<=207; -完成一個(gè)周期 when others=>NULL; end

25、 case; elsif k=167 then case tmp is when 00=>d<=167; when 01=>d<=166; when 02=>d<=165; -上升曲線 when 03=>d<=163; when 04=>d<=162; when 05=>d<=155; when 06=>d<=151; when 07=>d<=146; when 08=>d<=141; when 09=>d<=134; when 10=>d<=128; when

26、11=>d<=121; when 12=>d<=113; when 13=>d<=105; when 14=>d<=97; when 15=>d<=89; when 16=>d<=81; when 17=>d<=73; when 18=>d<=64; when 19=>d<=56; when 20=>d<=49; when 21=>d<=42; when 22=>d<=34; when 23=>d<=28; when 24=>d<

27、;=22; when 25=>d<=17; when 26=>d<=12; when 27=>d<=8; when 28=>d<=5; when 29=>d<=3; when 30=>d<=1; when 31=>d<=0; when 32=>d<=0; -下降曲線 when 33=>d<=1; when 34=>d<=3; when 35=>d<=5; when 36=>d<=8; when 37=>d<=12; when 38=>

28、d<=17; when 39=>d<=22; when 40=>d<=28; when 41=>d<=34; when 42=>d<=42; when 43=>d<=49; when 44=>d<=56; when 45=>d<=64; when 46=>d<=73; when 47=>d<=81; when 48=>d<=89; when 49=>d<=97; when 50=>d<=105; when 51=>d<=113; wh

29、en 52=>d<=121; when 53=>d<=128; when 54=>d<=134; when 55=>d<=141; when 56=>d<=146; when 57=>d<=151; when 58=>d<=155; when 59=>d<=162; when 60=>d<=163; when 61=>d<=165; when 62=>d<=166; when 63=>d<=167; -完成一個(gè)周期 when others=>NU

30、LL; end case; elsif k=119 then case tmp is when 00=>d<=119; when 01=>d<=118; when 02=>d<=117; -上升曲線 when 03=>d<=116; when 04=>d<=114; when 05=>d<=112; when 06=>d<=109; when 07=>d<=105; when 08=>d<=101; when 09=>d<=97; when 10=>d<=92;

31、when 11=>d<=87; when 12=>d<=81; when 13=>d<=76; when 14=>d<=70; when 15=>d<=64; when 16=>d<=58; when 17=>d<=52; when 18=>d<=46; when 19=>d<=41; when 20=>d<=35; when 21=>d<=30; when 22=>d<=25; when 23=>d<=20; when 24=>d&

32、lt;=16; when 25=>d<=12; when 26=>d<=9; when 27=>d<=6; when 28=>d<=4; when 29=>d<=2; when 30=>d<=1; when 31=>d<=0; when 32=>d<=0;-下降曲線 when 33=>d<=1; when 34=>d<=2; when 35=>d<=4; when 36=>d<=6; when 37=>d<=9; when 38=>d

33、<=12; when 39=>d<=16; when 40=>d<=20; when 41=>d<=25; when 42=>d<=30; when 43=>d<=35; when 44=>d<=41; when 45=>d<=46; when 46=>d<=52; when 47=>d<=58; when 48=>d<=64; when 49=>d<=70; when 50=>d<=76; when 51=>d<=81; when

34、52=>d<=87; when 53=>d<=92; when 54=>d<=97; when 55=>d<=101; when 56=>d<=105; when 57=>d<=109; when 58=>d<=112; when 59=>d<=114; when 60=>d<=116; when 61=>d<=117; when 62=>d<=118; when 63=>d<=119; -完成一個(gè)周期 when others=>NULL; en

35、d case; end if; end if; end process;end;分析:與三角波一樣,正弦波也是采用點(diǎn)連成曲線的方法完成的。d、鋸齒波實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity juchi is port(clk,clr:in std_logic; k:in integer range 0 to 255; -幅度選擇信號 q:out integer range 0 to 255);end juchi;architecture juchi_arc o

36、f juchi isbegin process(clk,clr) variable num:integer range 0 to 255; variable ff:std_logic; -上升沿/下降沿判斷標(biāo)志,為0時(shí)上升,為1時(shí)下降 begin if clr='0' then -異步復(fù)位端 num:=0; elsif clk'event and clk='1' then -上升沿 if ff='0' then -ff=0,上升沿,直線 num:=k; ff:='1' else if num=7 then num:=0;

37、ff:='0' else num:=num-8; -ff=1,下降沿,每個(gè)脈沖減8 end if; end if; end if; q<=num; end process;end juchi_arc;分析:鋸齒波建立在三角波的基礎(chǔ)上,但在下降時(shí)用一條直線表示,周期是三角波的兩倍。e、階梯波實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jieti is port(clk,clr:in std_logic; k:in integer range

38、0 to 255; -幅度選擇信號 y:out integer range 0 to 255);end;architecture jieti_arc of jieti issignal d,tmp:integer range 0 to 255;begin process(clk,clr,k,tmp) begin if clr='0' then d<=0; elsif clk'event and clk='1' then if tmp=63 then tmp<=0; else tmp<=tmp+1; end if; if k=255 th

39、en case tmp is when 00=>d<=255; -每八個(gè)脈沖一個(gè)臺階; when 07=>d<=191; when 15=>d<=127; when 23=>d<=63; when 31=>d<=0; when 39=>d<=63; when 47=>d<=127; when 55=>d<=191; when 63=>d<=255; when others=>d<=d; end case; elsif k=207 then case tmp is when 0

40、0=>d<=207; when 07=>d<=155; when 15=>d<=103; when 23=>d<=51; when 31=>d<=0; when 39=>d<=51; when 47=>d<=103; when 55=>d<=155; when 63=>d<=207; -完成一個(gè)周期 when others=>d<=d; end case; elsif k=167 then case tmp is when 00=>d<=167; -每八個(gè)脈沖一個(gè)

41、臺階; when 07=>d<=125; when 15=>d<=83; when 23=>d<=41; when 31=>d<=0; when 39=>d<=41; when 47=>d<=83; when 55=>d<=125; when 63=>d<=167; when others=>d<=d; end case; elsif k=119 then case tmp is when 00=>d<=119; -每八個(gè)脈沖一個(gè)臺階; when 07=>d<=8

42、9; when 15=>d<=59; when 23=>d<=29; when 31=>d<=0; when 39=>d<=29; when 47=>d<=59; when 55=>d<=89; when 63=>d<=119; when others=>d<=d; end case; end if; end if; end process; y<=d;end;分析:階梯波每八個(gè)脈沖上升十個(gè)點(diǎn)。f、梯形波實(shí)體框圖程序清單:library ieee;use ieee.std_logic_1164

43、.all;use ieee.std_logic_unsigned.all;entity tixing is   port(clk,clr:in std_logic;        k:in integer range 0 to 255;       -幅度選擇信號        q:out integer range 0 to 255);end tixing;architect

44、ure a of tixing isbegin      process(clk,clr)          variable num,n:integer range 0 to 255; -n計(jì)數(shù)          variable ff:integer range 0 to 2;    -ff上升沿/下降沿判斷標(biāo)志,為0時(shí)上升,為1時(shí)上

45、底邊,為2時(shí)下降   begin       if clr='0' then                                -異步復(fù)位端   

46、60;        num:=0;       elsif clk'event and clk='1' then               -上升沿         if ff=0 then  

47、0;        if num=k-7 then              num:=k;                          

48、60;           ff:=1;           else              num:=num+8;n:=n+1;           &#

49、160;          -ff=0,每個(gè)上升沿脈沖加8           end if;         elsif ff=1 then            if n=0 then   

50、60;          ff:=2;            else num:=num;                  n:=n-1;       

51、60;    end if;          else              if num=7 then                 num:=0;  

52、0;               ff:=0;              else                  num:=num-8;  

53、60;                      -ff=2,下降沿,每個(gè)脈沖減8              end if;           end if;        end if;        q<=num;       end process;end a; 分析:當(dāng)輸入幅度為255時(shí),梯形波在前三分之一個(gè)周期在上升,中間三分之一保持高電平直線,后三分之一下降。仿真波形如上。3.5 輸出模塊實(shí)體框圖程序清單:library ieee;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(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

提交評論