Forum Discussion
Altera_Forum
Honored Contributor
14 years agoBasically you need some background on NCO functionality. You create a LUT containing one cycle worth of sine/cos data. Then once you choose a frequency, you need to find out how to do the phase (such as your when 45), here 45 represents the value of an accumulator for phase that will point at the LUT at that moment.
phase starts with say zero then you increment it by some fixed value depending on frequency to be generated. if your sampling frequency is Fs and your accumulator is 2^12 then to calculate phase increment from frequency: f = Fs * inc/2^12 hence inc = f/Fs *2^12 Hence add inc modulo 2^12: 0 => inc => 2inc => 3 inc => ...etc then allow rollover. at each addition the result of adder points to LUT. You may use larger accumulator then use 12 MSBs of its result. This gives better phase resolution for same given LUT. Alternatively you can use larger LUT...