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

How to create sine and cos waves of different frequencies using Cyclone III(VHDL)

Altera_Forum
Honored Contributor II
1,604 Views

Hi, 

 

Is there anyone can help me to deal with one problem: How to create sine or cos waves in Cyclone III FPGA in VHDL. I have no clear idea to program the VHDL code although I have search some documents. 

 

I will be much appreciate if someone can help me out. 

 

Thank you very much. 

 

Best wishes, 

 

peipei
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
491 Views

If you have no VHDL knowledge, my first suggestion would be to find a good tutorial and get yourself familiar with the language. 

 

As for the sin waves, sine and cosine are identical, but with a phase shift. It would be easy enough to build a ROM of sin values in VHDL and just read them out.
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Or read up on Goertzel.

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

There are many methods that can be used, A simple lookup table is the easiest, then just step through the lookup table at different rates. 

 

If you truly want to generate Sin and Cos values, a CORDIC algorithm is the way to go. 

 

Pete
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

If it was me I will use the altera ip away from manual hdl coding. I think cordic is too much for a beginner to hand code or understand.

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

 

--- Quote Start ---  

If it was me I will use the altera ip away from manual hdl coding. I think cordic is too much for a beginner to hand code or understand. 

--- Quote End ---  

 

Does altera provide cordic IP for user now?
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Hi Tricky, 

 

I have learnt VHDL and I suppose I have some knowledge of this language. 

 

But just for this application, I have not clear idea to achieve this. 

 

In my mind, I want to use Look up table, due to the ADA board is 14 bits, and I have generated the different values in Excel for one cycle, I am not sure should I generate all 2^14 values or not. 

 

Thanks for your reply. 

 

Best wishes, 

 

peipei 

--- Quote Start ---  

If you have no VHDL knowledge, my first suggestion would be to find a good tutorial and get yourself familiar with the language. 

 

As for the sin waves, sine and cosine are identical, but with a phase shift. It would be easy enough to build a ROM of sin values in VHDL and just read them out. 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Hi Jerry, 

 

I am planning to use LUT. 

 

Do you have specific suggestions? My ADA board is 14 bits. 

 

Thanks, 

 

Best wishes, 

 

peipei 

--- Quote Start ---  

Does altera provide cordic IP for user now? 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Remember Sin and cosine are reflective, so you only need 2^13 values in the rom, you use the 14th bit as the sign bit.

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

CORDIC is suitable for generating the sin/cos of an angle. 

You can generate sin(a + delta) from sin(a - delta) and sin(a) with a single multiply (and a shift). 

The only slight problen is that the amplitude can drift.
0 Kudos
Reply