What's your sine? Finding the right algorithm for digital frequency synthesis on a DSP
Perhaps the most fundamental building block of all communication equipment is the sine wave generator. We have ample knowledge of how to generate sine waves using analog electronic hardware. In modern electronics, however, more and more functions once performed by analog circuitry are now performed by digital signal processors or field-programmable gate arrays. Those two types of ICs are the main approaches for developing and implementing signal processing: either the programmable DSP or the ASIC/FPGA.
Lately, high-performance DSPs are using concepts, such as execution pipelining and parallelism of operations, which were unknown to their ancestor the CPU but routine to the FPGA world. DSPs are starting to resemble FPGAs more and more, and although some fundamental differences remain, this hybridization makes it possible to use algorithms originally developed for one environment in the other.
For instance, you can use a very efficient algorithm for computing the sine for an arbitrary phase in a programmable DSP. The method is not new in itself but adapts the original ideas applied to the design of direct digital frequency synthesizer (DDFS) ICs over two decades ago.
It's important to highlight at this point a crucial difference between algorithms used to compute the sine of a random input phase and those that generate a sine wave. While a sine computation algorithm can be easily converted into a sine wave generator, by providing to its input a monotonically increasing phase sequence, it's absolutely impractical, if not impossible, to use a sine wave generator to calculate the sine of a random phase input.
We'll differentiate these algorithms as sine computation and sine generation with the understanding that a sine computation is a more general method and hence can be easily converted into the latter without significant additional complexity.
In this article, we'll review the most common methods for the computing and generating a sine wave on a programmable DSP, as well as provide a brief introduction to direct digital frequency synthesis (DDFS). We'll then describe a new approach to DDFS based on an algorithm created by combining lookup tables and trigonometric identities. The approach lends itself well to implementation on DSPs such as the Texas Instruments' C6x.
Sine generation in a programmable DSP
Implementing a high-speed sine-wave synthesizer in a programmable DSP is hardly a trivial task; it often requires a careful trade-off between memory and implementation complexity. The problem arises because the standard algorithms used to calculate Sin(x), as well as any other transcendental function of x, are based on the Taylor series expansion of the function in question, which is a time-consuming procedure. Hence, for a given finite number of CPU cycles, only a limited number of results can be rendered in real time. Several alternative algorithms have been developed to boost the performance of the sine-wave generation. Table 1 presents some of the most popular sine generation and computation algorithms used in a DSP.