Generate real or complex sinusoidal signals—optimized for HDL code generation

The HDL NCO System object™ generates real or complex sinusoidal signals, while providing hardware-friendly control signals. The object uses the same phase accumulation and lookup table algorithm as implemented in the NCO System object. The object uses quantized integer accumulation to create a sinusoid signal.

The HDL NCO System object provides these features.

Optional frame-based output.

A lookup table compression option to reduce the lookup table size. This compression results in less than one LSB loss in precision. See Lookup Table Compression for more information.

An optional input argument for external dither.

An optional reset argument that resets the phase accumulator to its initial value.

An optional output argument for the current NCO phase.

Given a desired output frequency *F*_{0}, calculate
the *phase increment* input value using

$$phaseincrement=(\frac{{F}_{0}\cdot {2}^{N}}{{F}_{s}})$$

, where *N* is the quantized accumulator word length and

$${F}_{s}=\frac{1}{{T}_{s}}=\frac{1}{sampletime}$$

. You can specify the phase increment using a propety or an input argument.

The frequency resolution of an NCO is defined by

$$\Delta f=\frac{1}{{T}_{s}\cdot {2}^{N}}\text{Hz}$$

Given a desired phase offset (in radians), calculate the *phase offset*
input value using

$$phaseoffset=\frac{{2}^{N}\cdot desiredphaseoffset}{2\pi}$$

You can specify the phase offset using a property or an input argument.

To generate real or complex sinusoidal signals:

Create the

`dsp.HDLNCO`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

creates a numerically
controlled oscillator (NCO) System
object, `hdlnco`

= dsp.HDLNCO`hdlnco`

, that generates a real or complex sinusoidal
signal. The amplitude of the generated signal is always 1.

sets properties using one or more name-value pairs. Enclose each property name in single
quotes. For example,
`hdlnco`

= dsp.HDLNCO(`Name,Value`

)

hdlnco = dsp.HDLNCO('NumQuantizerAccumulatorBits',12, ... 'AccumulatorWL',16);

creates an NCO with the `hdlnco`

= dsp.HDLNCO(`Inc`

,'PhaseIncrementSource','Property')`PhaseIncrement`

property set to
`Inc`

, an integer scalar. To use the PhaseIncrement
property, set the PhaseIncrementSource property to `'Property'`

. You can add
other `Name,Value`

pairs before or after
`PhaseIncrementSource`

.

The object returns the waveform value, `Y`

, as a sine value, a cosine
value, a complex exponential value, or a [`Sine,Cosine`

] pair of values,
depending on the Waveform property.

`[`

returns a waveform, `Y`

,`ValidOut`

]
= hdlnco (`ValidIn`

)`Y`

, using waveform parameters from properties
rather than input arguments.

To use this syntax, set the PhaseIncrementSource, PhaseOffsetSource, and DitherSource
properties to `'Property'`

. These properties are independent of each
other. For example:

hdlnco = dsp.HDLNCO('PhaseIncrementSource','Property', ... 'PhaseIncrement',phIncr,... 'PhaseOffset',phOffset,... 'NumDitherBits',4)

`[`

returns a waveform, `Y`

,`ValidOut`

]
= hdlnco(`Inc`

,`Offset`

,`Dither`

,`ValidIn`

)`Y`

, with phase increment,
`Inc`

, phase offset, `Offset`

, and dither,
`Dither`

.

This syntax applies when you set the PhaseIncrementSource, PhaseOffsetSource, and DitherSource
properties to `'Input port'`

. These properties are independent of each
other. You can mix and match the activation of these arguments.
`PhaseIncrementSource`

is `'Input port'`

by default.
For example:

hdlnco = dsp.HDLNCO('PhaseOffsetSource','Input port',... 'DitherSource','Input port') for k = 1:1/Ts y(k) = hdlnco(phIncr,phOffset,ditherBits,true); end

`[___] = hdlnco(___,`

resets the accumulator value, but does not reset the output samples in the pipeline. If
`ResetAccum`

,`ValidIn`

)`ValidIn`

is `true`

, then the object continues to
generate the output waveform starting from the reset accumulator value.

To use this syntax, set the ResetAction
property to `1`

(`true`

). This syntax can include any of
the arguments from other syntaxes.

To use an object function, specify the
System
object as the first input argument. For
example, to release system resources of a System
object named `obj`

, use
this syntax:

release(obj)

[1] Cordesses, L., "Direct Digital
Synthesis: A Tool for Periodic Wave Generation (Part 1)." *IEEE Signal Processing
Magazine*. Volume 21, Issue 4, July 2004, pp. 50–54.