Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20725 Discussions

sine wave generation

Altera_Forum
Honored Contributor II
1,257 Views

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

0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
495 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

thank you Socrates ...

0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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;
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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

 

Ciao!
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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?

0 Kudos
Altera_Forum
Honored Contributor II
495 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
495 Views

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

0 Kudos
Reply