FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6379 Discussions

## Floating point modules MegaWizard question

Honored Contributor II
901 Views

Hello people!

I want to implement a small sinewave generator inside my Cyclone IV E using some of the floating point operations in the MegaWizard.

I have two simple questions:

First of all, should the input in the SINCOS module be in radians (0 - 2*pi) or in degrees (0 - 360)?

And the second question is how does the output latency work? In time t=0 it takes the input and does calculations for the cycles required while neglecting input until it finishes, and then it takes the next input at cycle (t=0 + latency) again, or does it work in a queue taking all inputs sequentially?

5 Replies
Honored Contributor II
227 Views

Altera forgot to mention the angle unit in the users guide, I presume it's radian as with altfp_atan.

Pipelined IP can process new input values every clock cycle.
Honored Contributor II
227 Views

--- Quote Start ---

Pipelined IP can process new input values every clock cycle.

--- Quote End ---

And the result appears N clocks later, so any signals in parrallel to the data not being processed need to be delayed by N clocks also.
Honored Contributor II
227 Views

Do you want a sine wave, or to you want to experiment with the FP megawizard?

If you want a sine wave either use a Goertzel generator or a square wave and a low pass filter.

The Goertzel generator might suffer from amplitude drift. If you only need specific frequencies and amplitudes you can verify that the values eventually repeat - indicating stable amplitude.

Basically: sin(a+b) = 2sin(a)cos(b) - sin(a-b), so you can generate the next term of a sine wave from the previous 2 terms a constant (cos(b)) with a single multiply and a subtract.
Honored Contributor II
227 Views

--- Quote Start ---

If you want a sine wave either use a Goertzel generator or a square wave and a low pass filter.

--- Quote End ---

Or the Quartus NCO MegaFunction.
Honored Contributor II
227 Views