Verilog語(yǔ)言編寫正弦波,鋸齒波,余弦波程序?qū)崿F(xiàn)數(shù)控振蕩器_第1頁(yè)
Verilog語(yǔ)言編寫正弦波,鋸齒波,余弦波程序?qū)崿F(xiàn)數(shù)控振蕩器_第2頁(yè)
Verilog語(yǔ)言編寫正弦波,鋸齒波,余弦波程序?qū)崿F(xiàn)數(shù)控振蕩器_第3頁(yè)
Verilog語(yǔ)言編寫正弦波,鋸齒波,余弦波程序?qū)崿F(xiàn)數(shù)控振蕩器_第4頁(yè)
全文預(yù)覽已結(jié)束

下載本文檔

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

文檔簡(jiǎn)介

1、module sin(reset,clk,sync,freq,sin_out,cos_out; input reset; input clk; input sync; input 7:0 freq; output 7:0 sin_out; output 7:0 cos_out; reg 7:0 sin_out; reg 7:0 cos_out; reg 7:0 phase; reg 5:0 max_phase; reg 7:0 output_zeros; reg 5:0 sin_index; reg 7:0 sin_table; reg 1:0 phase_d1; reg 1:0 phase_

2、d2; reg 5:0 cos_index; reg 7:0 cos_table; assign saw_out=phase15 : 8; always(posedge reset or posedge clk begin if (reset=1'b1 phase<=8'b0; else begin if (sync=1'b1 phase<=8'b0; else phase<=phase+freq; end end always(posedge clk or posedge reset begin if (reset=1'b1 phas

3、e=8'b0000000; else if(clk begin if (sync=1'b1 phase=8'b00000000; else phase=phase+freq; end end always (posedge clk or posedge reset begin if (reset=1'b1 begin sin_index =1'b0; phase_d1 =2'b00; end else if(clk begin phase_d1=phase7 : 6; if (phase6=1'b0 sin_index=phase5:0;

4、 else sin_index=max_phase-phase5 : 0; end end always(posedge clk or posedge reset begin if (reset=1'b1 begin sin_index =1'b0; phase_d2 =2'b00; end else if(clk begin phase_d2 =phase_d1; case (sin_index5:0 6'b000000 : sin_index=8'b00000000; 6'b000001 : sin_index=8'b00000011

5、; 6'b000010 : sin_index=8'b00000110; 6'b000011 : sin_index=8'b00001001; 6'b000100 : sin_index=8'b00001100; 6'b000101 : sin_index=8'b00001111; 6'b000110 : sin_index=8'b00010010; 6'b000111 : sin_index=8'b00010101; 6'b001000 : sin_index=8'b0001100

6、0; 6'b001001 : sin_index=8'b00011011; 6'b001010 : sin_index=8'b00011110; 6'b001011 : sin_index=8'b00100001; 6'b001100 : sin_index=8'b00100100; 6'b001101 : sin_index=8'b00100111; 6'b001110 : sin_index=8'b00101010; 6'b001111 : sin_index=8'b001011

7、01; 6'b010000 : sin_index=8'b00110000; 6'b010001 : sin_index=8'b00110011; 6'b010010 : sin_index=8'b00110110; 6'b010011 : sin_index=8'b00111001; 6'b010100 : sin_index=8'b00111011; 6'b010101 : sin_index=8'b00111110; 6'b010110 : sin_index=8'b01000

8、001; 6'b010111 : sin_index=8'b01000011; 6'b011000 : sin_index=8'b01000110; 6'b011001 : sin_index=8'b01001001; 6'b011010 : sin_index=8'b01001011; 6'b011011 : sin_index=8'b01001110; 6'b011100 : sin_index=8'b01010000; 6'b011101 : sin_index=8'b0101

9、0010; 6'b011110 : sin_index=8'b01010101; 6'b011111 : sin_index=8'b01010111; 6'b100000 : sin_index=8'b01011001; 6'b100001 : sin_index=8'b01011011; 6'b100010 : sin_index=8'b01011110; 6'b100011 : sin_index=8'b01100000; 6'b100100 : sin_index=8'b011

10、00010; 6'b100101 : sin_index=8'b01100100; 6 9;b100110 : sin_index=8'b01100110; 6'b100111 : sin_index=8'b01100111; 6'b101 000 : sin_index=8'b01101001; 6'b101001 : sin_index=8'b01101011; 6'b101010 : sin_index=8'b01101100; 6'b101011 : sin_index=8'b011

11、01110; 6'b101100 : sin_index=8'b01110000; 6'b101101 : sin_index=8'b01110001; 6'b101110 : sin_index=8'b01110010; 6'b101111 : sin_index=8'b01110100; 6'b110000 : sin_index=8'b01110101; 6'b110001 : sin_index=8'b01110110; 6'b110010 : sin_index=8'b01

12、110111; 6'b110011 : sin_index=8'b01111000; 6'b110100 : sin_index=8'b01111001; 6'b110101 : sin_index=8'b01111010; 6'b110110 : sin_index=8'b01111011; 6'b110111 : sin_index=8'b01111011; 6'b111000 : sin_index=8'b01111100; 6'b111001 : sin_index=8'b0

13、1111101; 6'b111010 : sin_index=8'b01111101; 6'b111011 : sin_index=8'b01111110; 6'b111100 : sin_index=8'b01111110; 6'b111101 : sin_index=8'b01111110; 6'b111110 : sin_index=8'b01111110; 6'b111111 : sin_index=8'b01111110; default : sin_index=8'b000000

14、00; endcase end end always(posedge clk or posedge reset begin if (reset=1'b1 sin_out =1'b0; else if (clk begin if (phase_d21=1'b0 sin_out = sin_table; else sin_out=output_zeros-sin_table; end end always (posedge clk or posedge reset begin if (reset=1'b1 cos_index =1'b0; else if(c

15、lk begin if (phase6=1'b0 cos_index=phase5:0; else cos_index=max_phase-phase5 : 0; end end always(posedge clk or posedge reset begin if (reset=1'b1 cos_table =1'b0; else if(clk case (cos_index5:0 6'b000000 : cos_table=8'b01111111; 6'b000001 : cos_table=8'b01111110; 6'b

16、000010 : cos_table=8'b01111110; 6'b000011 : cos_table=8'b01111110; 6'b000100 : cos_table=8'b01111110; 6'b000101 : cos_table=8'b01111110; 6'b000110 : cos_table=8'b01111101; 6'b000111 : cos_table=8'b01111101; 6'b001000 : cos_table=8'b01111100; 6'

17、b001001 : cos_table=8'b01111011; 6'b001010 : cos_table=8'b01111011; 6'b001011 : cos_table=8'b01111010; 6'b001100 : cos_table=8'b01111001; 6'b001101 : cos_table=8'b01111000; 6'b001110 : cos_table=8'b01110111; 6'b001111 : cos_table=8'b01110110; 6'

18、;b010000 : cos_table=8'b01110101; 6'b010001 : cos_table=8'b01110100; 6'b010010 : cos_table=8'b01110010; 6'b010011 : cos_table=8'b01110001; 6'b010100 : cos_table=8'b01110000; 6'b010101 : cos_table=8'b01101110; 6'b010110 : cos_table=8'b01101100; 6

19、9;b010111 : cos_table=8'b01101011; 6'b011000 : cos_table=8'b01101001; 6'b011001 : cos_table=8'b01100111; 6'b011010 : cos_table=8'b0110011 0; 6'b011011 : cos_table=8'b01100100; 6'b011100 : cos_table=8'b01100010; 6'b011101 : cos_table=8'b01100000; 6&

20、#39;b011110 : cos_table=8'b01011110; 6'b011111 : cos_table=8'b01011011; 6'b100000 : cos_table=8'b01011001; 6'b100001 : cos_table=8'b01010111; 6'b100010 : cos_table=8'b01010101; 6'b100011 : cos_table=8'b01010010; 6'b100100 : cos_table=8'b01010000; 6

21、'b100101 : cos_table=8'b01001110; 6'b100110 : cos_table=8'b01001011; 6'b100111 : cos_table=8'b01001001; 6'b101000 : cos_table=8'b01000110; 6'b101001 : cos_table=8'b01000011; 6'b101010 : cos_table=8'b01000001; 6'b101011 : cos_table=8'b00111110;

22、6'b101100 : cos_table=8'b00111011; 6'b101101 : cos_table=8'b00111001; 6'b101110 : cos_table=8'b00110110; 6'b101111 : cos_table=8'b00110011; 6'b110000 : cos_table=8'b00110000; 6'b110001 : cos_table=8'b00101101; 6'b110010 : cos_table=8'b00101010; 6'b110011 : cos_table=8'b00100111; 6'b110100 : cos_ta

溫馨提示

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