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

Floating point modules MegaWizard question

Altera_Forum
Honored Contributor II
886 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? 

 

Thanks a lot in advance!
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
212 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.
0 Kudos
Altera_Forum
Honored Contributor II
212 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.
0 Kudos
Altera_Forum
Honored Contributor II
212 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.
0 Kudos
Altera_Forum
Honored Contributor II
212 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.
0 Kudos
Altera_Forum
Honored Contributor II
212 Views

Thanks a lot for your answers! 

 

Basically I just wanted to create a reference for PWM creation, but I used a slow custom updown counter. Now I am having problems with Timing requirements. I have my external crystal clock for DE0 Nano and inside the chip I have two PLLs (450MHz and 75MHz), some state machines and some other custom code. The code simulate4s perfectly but doesnt run correctly. I removed all warnings and now I try to see where the problem is. 

 

I changed the first PLL to 150MHz (that PLL is used for the PWM creation) and now it works. I constantly have a timing requirements not met and I was wondering what is the easiest way to tell the compiler to fit my design for 450MHz
0 Kudos
Reply