Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20764 ディスカッション

sine wave generation

Altera_Forum
名誉コントリビューター II
1,293件の閲覧回数

can anyone please give me idea about how to generate sine wave in vhdl.....please

0 件の賞賛
10 返答(返信)
Altera_Forum
名誉コントリビューター II
531件の閲覧回数

Search the forum, there's a file hosted somewhere here.

Altera_Forum
名誉コントリビューター II
531件の閲覧回数

I think many people will recommend a look up table approach, while others will recommend the Cordic based method. My recommendation is to implement a cordic in rotation mode, and simply feed it a constant X value, and set Y to zero, and make the angle correspond to a frequency that you wish the fundamental output to be. Then you will get both sine and cosine, with no lookup table, and small resource usage. James

Altera_Forum
名誉コントリビューター II
531件の閲覧回数

hi james, first thank you very much for giving reply. actually i already tried with cordic rotation method,,,but i didn't get it may be i think i'm not going with correct path in coding, so that i'm looking towards lookup table method.., i'm very glad to you if you provide me some info on cordic algorithm.

Altera_Forum
名誉コントリビューター II
531件の閲覧回数

lookup goertlez's algorithm. 

Basically: 

sin(a+b) = sin(a)cos(b) - cos(a)sin(b) 

sin(a-b) = sin(a)cos(b) + cos(a)sin(b) 

so: 

sin(a+b) = 2sin(a)cos(b) - sin(a-b) 

and you can generate the terms in sequence with a multiply and an add
Altera_Forum
名誉コントリビューター II
531件の閲覧回数

thank you Socrates ...

Altera_Forum
名誉コントリビューター II
531件の閲覧回数

Hi guys 

 

I'm working on an audio synthesizer.  

I used a "case" using exel (for calculate function).  

you can use matlab too.  

 

vhdl code exemple: 

 

case nTHETA is --Table (wave) 

 

WHEN 1 => SINE_TMP := 32799 ; 

WHEN 2 => SINE_TMP := 32832 ; 

WHEN 3 => SINE_TMP := 32865 ; 

WHEN 4 => SINE_TMP := 32898 ; 

 

... 

 

WHEN 6280 => SINE_TMP := 32662 ; 

WHEN 6281 => SINE_TMP := 32695 ; 

WHEN 6282 => SINE_TMP := 32728 ; 

WHEN 6283 => SINE_TMP := 32760 ; 

WHEN others => SINE_TMP := 0 ; 

 

end case;
Altera_Forum
名誉コントリビューター II
531件の閲覧回数

If you use google translator to translate italian see delucagiovanni.com/public/phpbb3/viewtopic.php?f=10&t=269 

 

Ciao!
Altera_Forum
名誉コントリビューター II
531件の閲覧回数

instead of a laborious case statement, why not use a constant that is set up via a function using the cos/sin function from the math_real library?

Altera_Forum
名誉コントリビューター II
531件の閲覧回数

 

--- Quote Start ---  

instead of a laborious case statement, why not use a constant that is set up via a function using the cos/sin function from the math_real library? 

--- Quote End ---  

 

 

simply because they knew that library 

thank you! 

 

i will check now
Altera_Forum
名誉コントリビューター II
531件の閲覧回数

thank you very much friends for your great suggestions and for good discussion.....

返信